Automating control chart with multiple date columns and data columnsHello,
I am trying to automate a way to build control charts from a table formatted like below,
| Engine | 314-Date | 314-Parameter 1 | 314-parameter 2 | 314-Parameter ect. | 213-parameter 1 | 213- date | 241-parameter 1 | 241-parameter 2 | 241-Date |
| # | date | # | # | # | # | date | # | # | date |
| # | date | # | # | # | # | date | # | # | date |
I have this code which gets me close to what I want.
Rcols = dt << GetColumnNames( Continuous, String );
nw = New Window( "Control Charts", myVLB = V List Box() );
For( i = 1, i <= N Items( Rcols ), i++,
cc = Control Chart(
Sample Label( Column( dt, Rcols[1] ) ),
KSigma( 3 ),
Chart Col( Column( dt, Rcols[i] ), Levey Jennings )
);
myVLB << Append( Report( cc ) );
cc << close window;
);
However, the issue now is trying to find a way to make the sample label the correct date for the ID of the parameters. There are not equal amounts of parameters for each ID so the table is not uniform in that way, which also makes this a little more difficult.
Thanks!
Re: Automating control chart with multiple date columns and data columnsIt means that the item you are attempting to insert into is not a List. In this code:
a=3;
insert into(c,a)
you will get the error, since the variable "c" has not been defied as a list.
Re: Automating control chart with multiple date columns and data columnsHey Jim, I think this is really close to what I need. I am getting an error which is:
Can insert only into an L-value in access or evaluation of 'Insert Into'
Could you shine some light into what this means?
Thanks
Re: Automating control chart with multiple date columns and data columnsJim, posted before I finished my solution ... again. My approach is about the same, but I like to use a function created to work with lists which reduces a lot of code. The function which I call Lfunc( list, expr), runs the expression on each item in the list. [This has been a long time JMP wish list item].
So the 3rd line in the JSL below returns [2, 7 ,10] for the example you provided. For each of those columns I get the code, and the line that starts with "params=" returns all columns (not containing date) that begin with that code.
Other than an alternate approach and wish again for a JMP built in function something like Lfunc(), I noticed you are creating inactive control charts and maybe that is your goal. If you want "live" interactive charts, for highlighting and hover help, see the commented code in the attached file FindColumns_CC.jsl
dt=current data table();
Rcols = dt << GetColumnNames(String ); //get all coumns so the code can use the column number
dateCols = Loc(Matrix(Lfunc(RCols, Expr(Contains(Lowercase(x),"date"))))); //2,7,10
nw = New Window( "Control Charts", myVLB = V List Box() );
for(i=1, i<=nrow(dateCols), i++,
code = Trim(word(1, Rcols[dateCols[i]], "-"));
params = Loc(Matrix(Lfunc(RCols, Expr(StartsWith(x,code) & !Contains(lowercase(x),"date")) )));
Re: Automating control chart with multiple date columns and data columnsI believe I understand your question. I have taken the approach, to find all of the groups in the data, and to create a separate list of columns that are in each of the lists. Then, the groups are looped across them, and each of the columns in that list are processed I don't have a data table to test my solution with, so I believe the code should be used as a good guide of how to solve the problem, but should not be considered a definative solution
Rcols = dt << GetColumnNames( Continuous, String );
// Process the columns into group and separate lists for each group
groupList = {};
For( i = 2, i <= N Items( Rcols ), i++,
theGroup = Word( 1, Rcols[i], "-" );
// Check if the group has been seen before
If( Contains( groupList, theGroup ) > 0,
// If this is a new group, create a list to hold the column names
Eval( Parse( "Group_" || theGroup || " = {};" ) );
// Add the group name to the groupList
Insert Into( groupList, theGroup );
// Add the current parameter to the new group list
Insert Into( "Group_" || theGroup, Rcols[i] );
,
// If this isn't a new group list, then add it to the
// already existing group list
Insert Into( "Group_" || theGroup, Rcols[i] )
);
);
// Create the display window
nw = New Window( "Control Charts", myVLB = V List Box() );
// Loop across the groups
For( group = 1, group <= N Items( groupList ), group++,
// Set a standard list name to have the values of the current Group_list
Eval( Parse( "tempRcols = Group_" || groupList[group] || ";" ) );
// Generate the charts
For( i = 2, i <= N Items( tempRcols ), i++,
cc = Control Chart(
Sample Label( Column( dt, tempRcols[1] ) ),
KSigma( 3 ),
Chart Col( Column( dt, tempRcols[i] ), Levey Jennings )
);
myVLB << Append( Report( cc ) );
cc << close window;
);
);