Selecting multiple columns and do histogram in a scriptHi,
I have written a script to select two columns from a table and do histogram. I like to be able to select an arbitary number of columns and do histogram for selected one. Can one help me achieve that? I have liste my script below. Thanks
dt = Open( "A.csv" );
xvar = .;
yvar = .;
win = New Window( "Choose Two Variables",
<<Modal,
<<On Validate(
// require the user to select two variables before clicking OK
Show( xvar, yvar );
If( Is Missing( xvar ) | Is Missing( yvar ),
0, // if xvar or yvar are missing, do nothing when OK is clicked
1
);
),
Text Box( " Select two numeric columns. " ),
H List Box(
Text Box( " Choose First " ),
x = Col List Box(
dt, // data table reference
all, // display all columns from the data table
xvar = (x << Get Selected)[1];
// get the name of the selected column before the window closes
Show( xvar );
),
Text Box( "Choose Second" ),
y = Col List Box(
dt,
all,
yvar = (y << Get Selected)[1];
Show( yvar );
)
)
);
xcol = Column( dt, xvar ); // get the columns
ycol = Column( dt, yvar );
name1 = ":" || xvar;
name2 = ":" || yvar;
name = name1 || "," || name2;
Show( name );
Eval(
Parse(
"obj1 = Distribution(
Stack(1),
Continuous Distribution( Column(" || name1 || ") ,
),
Continuous Distribution( Column(" || name2 ||
"),
)
);"
)
);
Re: Selecting multiple columns and do histogram in a scriptThanks. That is very helpful script.Re: Selecting multiple columns and do histogram in a scriptHi,
Thanks again. I wanted to save the result of histogram into HTML and have done it in the past. Here is the script with some modification. I do get an error
Name Unresolved: obj in access or evaluation of 'obj'). I appreciate your help.
dt = Open( "A.csv" );
win = New Window( "Data Select",
H List Box(
Panel Box( "Available Columns", dtCols = Col List Box( dt, all, width( 80 ) ), ),
Panel Box( "Selected Columns",
H List Box(
V List Box(
addButton = Button Box( "Add", colList << Append( dtCols << Get Selected ) ),
removeButton = Button Box( "Remove", colList << Remove Selected() )
),
colList = Col List Box( numeric, width( 80 ), MinItems( 1 ), N Lines( 4 ) )
)
),
okButton = Button Box( "OK",
PlotCols = colList << Get Items;
str = "";
For( i = 1, i <= N Items( PlotCols ), i++,
str = str || "Continuous Distribution(Column(:Name(\!"" || plotcols[i] || "\!"))),
"
);
Eval( Parse( "obj = dt << Distribution(stack(1)," || str || ");" ) );
win << Close Window;
)
)
);
obj << report;
obj << Save Interactive HTML( "A" );
Re: Selecting multiple columns and do histogram in a scriptThanks so much for providing the solution. I tried it and it works.
Re: Selecting multiple columns and do histogram in a scriptHere's a method using colListBoxes:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
win = New Window("Data Select",
H List Box(
Panel Box("Available Columns",
dtCols = Col List Box(dt, all, width(80)),
),
Panel Box("Selected Columns",
H List Box(
V list Box(
addButton = Button Box("Add", colList << Append(dtCols << Get Selected) ),
removeButton = Button Box("Remove", colList << Remove Selected() )
),
colList = Col List Box(numeric, width(80), MinItems(1), N Lines(4))
)
),
okButton = Button Box("OK",
PlotCols = colList << Get Items;
str = "";
for(i=1,i<=N Items(PlotCols),i++,
str = str||"Continuous Distribution(Column(:Name(\!""||plotcols[i]||"\!"))),
"
);
eval(parse("dt << Distribution(stack(1),"||str||");"));
win << Close Window;
)
)
);