cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
SDF1
Super User

How to graph the last N values of a column?

Hi All,

  I'm still relatively new to JSL, so building my script codes as I move along.

 

  I'm trying to add to a control chart window the graph of the last 25 data points in a column of M values, e.g. colum(M-25) to (M).

 

  I'm thinking of modifying the chart builder script to do this:

Control Chart Builder(
	Size( 534, 454 ),
	Show Two Shewhart Charts( 0 ),
	Show Control Panel( 0 ),
	Show Limit Summaries( 0 ),
	Show Capability( 0 ),
	Variables( Y( :Name( "MyColumn" ) ) ),
	Chart(
		Points( Statistic( "Individual" ) ),
		Limits( Sigma( "Moving Range" ) ),
		Warnings( Test Beyond Limits( 1 ) )
	),
	SendToReport(
		Dispatch(
			{},
			"graph display 1 title",
			TextEditBox,
			{Set Text( "Last 25 Observations" )}
		),
		Dispatch( {}, "MyColumn Limit Summaries", OutlineBox, {Close( 1 )} )
	)
)

  The problem I'm having is how to chose only those last N values to display (N could be 25 or 30 or 100). My experience with other programming languages like Igor or Matlab aren't translating over to JSL for how to graph just a subset of data from a column.

 

  If possible, I'd prefer to have it plot the data vs row index, like in the control charts, and I know the Overlay plot can do that, but I also like having the Avg show up in the graph. I would prefer to NOT plot the data as a Fit Y by X.

 

Thanks!

13 REPLIES 13
ian_jmp
Level X

Re: How to graph the last N values of a column?

This seems to be a different question from the topic of the thread, but maybe try something like this:

Names DefaultToHere(1);

// Open a table and give it a table reference ('dt')
dt = Open("$SAMPLE_DATA/Big Class.jmp");

// Get a list of all the columns in the table
cols = dt << getColumnNames("String");

// Define any logical condition that identifies one or more columns by its name
targetCols = {};
for(c=1, c<=NItems(cols), c++, if(Contains(cols[c], "gh"), InsertInto(targetCols, cols[c])));

// Make a plot using'taregtCols' as the y variables
biv = dt << OneWay(X(:sex), Y(Eval(targetCols)));
EMC2
Level I

Re: How to graph the last N values of a column?

Thanks! Not sure i submitted my question correctly. I want to draw chart of a given big data set. But i need to check one particular column satisfies if condition and then if condition is satisfied then consider corresponding rows for plotting graph. I would like to do this through jsl script. Could you help me as am very beginner. Thanks!

txnelson
Super User

Re: How to graph the last N values of a column?

Names DefaultToHere(1);

// Open a table and give it a table reference ('dt')
dt = Open("$SAMPLE_DATA/Big Class.jmp");

// Select the data you do not want, and exclude them
dt << select where( :sex == "F" );
dt << hide and exclude;

// Clear the selections
dt << clear select;

// Create the chart, only none excluded/hidden rows will be displayed
dt << Graph Builder(
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 6 ) ), Smoother( X, Y, Legend( 7 ) ) )
);
Jim
EMC2
Level I

Re: How to graph the last N values of a column?

Thanks!