- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Automatically plot the associated columns in an Associative Array
With a lot of help from Jarmo, I got an Associative Array (aa) of columns that are linked. Next, I need to plot those, is that easily done
Names Default To Here(1);
startchar1 = "VT";
startchar2 = "ID";
rgx_startchar1 = Eval Insert("^startchar1^(.+?)$");
dt = Current Data Table();
collist = dt << get column names(string);
VT_IDcols = {};
For( i = 1, i <= N Items( collist ), i++,
If( !Contains( collist[i], "Pass/Fail"), If( Contains( collist[i], "VT") | Contains( collist[i], "ID") , Insert Into( VT_IDcols, collist[i] ))));
aa = Associative Array();
For Each({colname}, VT_IDcols,
col_ptrn = Regex(colname, rgx_startchar1, "\1");
If(!IsMissing(col_ptrn), // starts with VT and ends with H
If(Contains(VT_IDcols, startchar2 || col_ptrn ),
aa[startchar1 || col_ptrn] = startchar2 || col_ptrn;
);
);
);
Slán
SpannerHead
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Automatically plot the associated columns in an Associative Array
How you wish to plot those?
Names Default To Here(1);
endchar1 = "1";
endchar2 = "2";
rgx_endchar1 = Eval Insert("(.+?)^endchar1^$");
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
collist = dt << get column names(string);
aa = Associative Array();
For Each({colname}, collist,
col_ptrn = Regex(colname, rgx_endchar1, "\1");
If(!Is Missing(col_ptrn), // ends with H
If(Contains(collist, col_ptrn || endchar2),
aa[col_ptrn || endchar1] = col_ptrn || endchar2
)
);
);
// Plotting
lub = Lineup Box(N Col(2));
For Each({{xcol, ycol}}, aa,
lub << Append(dt << Bivariate(Y(Eval(xcol)), X(Eval(ycol))));
);
nw = new window("",
lub
);
-Jarmo
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Automatically plot the associated columns in an Associative Array
How you wish to plot those?
Names Default To Here(1);
endchar1 = "1";
endchar2 = "2";
rgx_endchar1 = Eval Insert("(.+?)^endchar1^$");
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
collist = dt << get column names(string);
aa = Associative Array();
For Each({colname}, collist,
col_ptrn = Regex(colname, rgx_endchar1, "\1");
If(!Is Missing(col_ptrn), // ends with H
If(Contains(collist, col_ptrn || endchar2),
aa[col_ptrn || endchar1] = col_ptrn || endchar2
)
);
);
// Plotting
lub = Lineup Box(N Col(2));
For Each({{xcol, ycol}}, aa,
lub << Append(dt << Bivariate(Y(Eval(xcol)), X(Eval(ycol))));
);
nw = new window("",
lub
);
-Jarmo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Automatically plot the associated columns in an Associative Array
Jarmo
Worked great! Tweaked it a bit to allow input selection.
Thanks
Names Default To Here(1);
dt = Current Data Table();
dt << Clear Column Selection();
colList = dt << get column names( string );
check_list = {"VT", "ID", "DI", "IK", "GM"};
check_list2 = {"0", "1", "2", "3", "8"};
New Window( "Select Variables",
<<Type( "Modal Dialog" ),
<<On Validate( window:validated ),
window:enable function = Function( {},
{Default Local},
X = window:lbMajor << Get Selected;
Y = window:lbMinor << Get Selected;
Voltage = window:lbVolt << Get Selected;
If( N Items( X ) & N Items( Y ) & X != Y,
window:validated = 1,
window:validated = 0
);
window:ok button << Enable( window:validated );
);
H List Box(
V List Box(
Text Box( "Select X Variable" ),
window:lbMajor = List Box(
check_list,
<<Set Max Selected( 1 ),
enable function
)
),
V List Box(
Text Box( "Select Y Variable" ),
window:lbMinor = List Box(
check_list,
<<Set Max Selected( 1 ),
enable function
)
),
V List Box(
Text Box( "Select Voltage" ),
window:lbVolt = List Box(
check_list2,
<<Set Max Selected( 1 ),
enable function
)
)
);,
H List Box(
window:ok button = Button Box( "OK",
X = window:lbMajor << Get Selected;
Y = window:lbMinor << Get Selected;
Voltage = window:lbVolt << Get Selected;
If( N Items( X ) & N Items( Y ) & X != Y,
window:validated = 1,
window:validated = 0
);
If( window:validated,
Print( "Processing with X: " || Char( X ) || ", Y: " || Char( Y ) );
Window( "Select Variables" ) << Close Window;
,
Beep();
Show( "Invalid Selection" );
{window:lbMajor, window:lbMinor} << Select;
window:lbMajor << Inval << Update Window;
Wait( 0.25 );
{window:lbMajor, window:lbMinor} << DeSelect;
window:lbMajor << Inval << Update Window;
Wait( 0.25 );
{window:lbMajor, window:lbMinor} << Select;
window:lbMajor << Inval << Update Window;
Wait( 0.25 );
{window:lbMajor, window:lbMinor} << DeSelect;
window:lbMajor << Inval << Update Window;
);,
<<Enable( 0 )
),
Button Box( "Cancel", Throw( "!Canceled Analysis" ) )
)
);
Show( X );
Show( Y );
Show( Voltage );
If(
X[1] == "VT", Xparam = "VT",
X[1] == "ID", Xparam = "ID",
X[1] == "DI", Xparam = "DI",
X[1] == "IK", Xparam = "IK",
X[1] == "GM", Xparam = "GM"
);
If(
Y[1] == "VT", Yparam = "VT",
Y[1] == "ID", Yparam = "ID",
Y[1] == "DI", Yparam = "DI",
Y[1] == "IK", Yparam = "IK",
Y[1] == "GM", Yparam = "GM"
);
If(
Voltage[1] == "0", Vnode = "0",
Voltage[1] == "1", Vnode = "1",
Voltage[1] == "2", Vnode = "2",
Voltage[1] == "3", Vnode = "3",
Voltage[1] == "8", Vnode = "8"
);
Show( Xparam );
Show( Yparam );
startchar1 = Xparam;
startchar2 = Yparam;
rgx_startchar1 = Eval Insert("^startchar1^(.+?)$");
dt = Current Data Table();
collist = dt << get column names(string);
//Paranmeter Group Filter
VT_IDcols1 = {};
For( i = 1, i <= N Items( collist ), i++,
If( !Contains( collist[i], "Pass/Fail"), If( Contains( collist[i], Xparam) | Contains( collist[i], Yparam) , Insert Into( VT_IDcols1, collist[i] ))));
//Voltage Filter
VT_IDcols = {};
For( i = 1, i <= N Items( VT_IDcols1 ), i++,
If( Contains( Munger( Head Name( As Namespace( VT_IDcols1[i] ) ), 0, 4 ), Vnode), Insert Into( VT_IDcols, VT_IDcols1[i] )
)
);
aa = Associative Array();
For Each({colname}, VT_IDcols,
col_ptrn = Regex(colname, rgx_startchar1, "\1");
If(!IsMissing(col_ptrn), // starts with VT and ends with H
If(Contains(VT_IDcols, startchar2 || col_ptrn ),
aa[startchar1 || col_ptrn] = startchar2 || col_ptrn;
);
);
);
show(aa);
// Plotting
lub = Lineup Box(N Col(2));
For Each({{xcol, ycol}}, aa,
lub << Append(dt << Bivariate(Y(Eval(xcol)), X(Eval(ycol))));
);
nw = new window("",
lub
);
Slán
SpannerHead