Check for column names before creating overlay plots in V List Box<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />I would like to create a V List Box of overlay plots only for those columns that exist in a data file. The names of the columns may change from file to file, or may be absent or present. I've been able to test for the presence of a column name before creating individual overlay plots, I can't figure out how to check for column names within a V List Box and for the V List Box to plot those overlay plots that correspond to existing columns and not hang when a column is absent. Any suggestions would be greatly appreciated.
dt = open("$sample_data\Big Class.jmp");
col_name_list = dt << get column names( string );
V List Box(
If( !Contains( col_name_list, :"height" ),
Overlay Plot(
X( :Name( "height" ) ),
Y( :Name( "weight" ) ),
Y Scale( Left, Right ),
Separate Axes( 1 ),
Connect Thru Missing( 1 )
),
);
If( !Contains( col_name_list, :"age" ),
Overlay Plot(
X( :Name( "age" ) ),
Y( :Name( "weight" ) ),
Y Scale( Left, Right ),
Separate Axes( 1 ),
Connect Thru Missing( 1 )
),
);
If( !Contains( col_name_list, :"ratio" ),
Overlay Plot(
X( :Name( "bmi" ) ),
Y( :Name( "weight" ) ),
Y Scale( Left, Right ),
Separate Axes( 1 ),
Connect Thru Missing( 1 )
),
);
);
Re: Check for column names before creating overlay plots in V List BoxThanks for your help with this. I was in a hurry and forgot to include the New Window command even though I knew that was required.
Re: Check for column names before creating overlay plots in V List BoxThe V List Box is just a display box. To actually see the box it must be put in a window.
New Window( "Name", V List Box(...));
Edit: Inserted the required title argument to New Window( )
Re: Check for column names before creating overlay plots in V List BoxWith the changes made as suggested it won't plot the OP's within the V List Box. I can create individual OP's if the V List Box is commented out. Interesting.
dt = open("$sample_data\Big Class.jmp");
col_name_list = dt << get column names( string );
V List Box(
If( Contains( col_name_list, "height" ),
Overlay Plot(
X( :Name( "height" ) ),
Y( :Name( "weight" ) ),
Y Scale( Left, Right ),
Separate Axes( 1 ),
Connect Thru Missing( 1 )
),
);
If( Contains( col_name_list, "age" ),
Overlay Plot(
X( :Name( "age" ) ),
Y( :Name( "weight" ) ),
Y Scale( Left, Right ),
Separate Axes( 1 ),
Connect Thru Missing( 1 )
),
);
If( Contains( col_name_list, "sex" ),
Overlay Plot(
X( :Name( "sex" ) ),
Y( :Name( "weight" ) ),
Y Scale( Left, Right ),
Separate Axes( 1 ),
Connect Thru Missing( 1 )
),
);
);
Re: Check for column names before creating overlay plots in V List BoxIt should work if you remove the Not operator ! before Contains() and the scoping colons before the strings inside Contains().
...
If( Contains( col_name_list, "height" ),
Overlay Plot(
X( :Name( "height" ) ),
Y( :Name( "weight" ) ),
Y Scale( Left, Right ),
Separate Axes( 1 ),
Connect Thru Missing( 1 )
),
);
...