Parse column names in Chart<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />This question is similar to another post about how to parse chart column names.
I want to create a simple bar chart where my Y columns are determined by user selection from a col list box.
I can't figure out a way to use parse and or expr to put my user selections into the chart statement.
For other types of charts (like Overlay), I have been able to use a list of columns to do this, but I can't
seem to do that with chart.
This code generates the graph when the Ycols are known:
dt = Open("$ENGLISH_SAMPLE_DATA/Big Class.jmp");
Chart (X( :name )
,
Y( :height, :weight )
);
When I have user selected YCols, I need to do something like this:
Chart1Expr= expr(Chart(
X(:name),
Y(ycols)
));
replaceycols = expr(:height, :weight) <- this doesn't work, but it's like what I neednewchartexpr = substitute(name expr(Chart1Expr), expr(ycols), expr(replaceycols));
newchartexpr;
Parse column names in ChartThank you! I'd been missing the Eval step when I tried feeding it a list.
Parse column names in ChartY() can accept a list as argument, even when the column names are represented by strings. This example works in JMP9:
dt = Open( "$ENGLISH_SAMPLE_DATA/Big Class.jmp" );
ycols = {"height", "weight"};
Chart( X( :sex ), Y( Eval( ycols ) ) );
However, if you need to specify any statistics it gets a little more complicated. One method is to build a list of expressions by looping through a list (e.g. generated by user) like in he below example:
dt = Open( "$ENGLISH_SAMPLE_DATA/Big Class.jmp" );
ycols = {};
For( i = 1, i <= N Items( ylist ), i++,
Insert Into( ycols, Parse( "Mean(:" || ylist[i] || ")" ) )
);
Chart( X( :sex ), Y( Eval( ycols ) ) );