cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Neo
Neo
Level VI

Pass items from calculated statistics to specific coordinates in a saved data-table

I generate several charts with calculated statistics. I would like to pass on specific calculated statistical parameters e.g. the minimum, median and maximum from Quantiles and Std Dev from Summary Statistics to specific coordinates in a saved data-table using JSL.

For example I would like pass on

  • minimum Quantile to row 5, column 7
  • median to row 5, column 8
  • maximum Quantile to row 5, column 9
  • Std Dev to row 5 column 10.

to my saved data-table. How to achive this using JSL?

(the coordinates are empty in the saved data table to start with)

When it's too good to be true, it's neither
16 REPLIES 16
Neo
Neo
Level VI

Re: Pass items from calculated statistics to specific coordinates in a saved data-table

@ron_horne . The following should help clear things up a bit more as it is very similar to my actual issue. I get the distribution plot via a function. 

Names Default To Here (1);

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

getDistChart = Function({ColName, _LSL, _USL}, {distChart},

New Window(""||ColName||" distribution",

Distribution(
	Stack( 1 ),
	Continuous Distribution(
		Column(As Column (ColName) ),
		Horizontal Layout( 1 ),
		Vertical( 0 ),
		Capability Analysis( LSL(_LSL ), USL(_USL) )
	),
	SendToReport(
		Dispatch(
			{},
			"Distrib Histogram",
			FrameBox,
			{DispatchSeg( LabelSeg( 1 ), {Font( "Segoe UI", 7, "Plain" )} ),
			DispatchSeg( LabelSeg( 2 ), {Font( "Segoe UI", 7, "Plain" )} )}
		)
	)
);
);

return(distChart);
);

dist = dt << getDistChart ("weight", 55, 185);

To me it appears that the last line is not doing what it is supposed to do for extracting values from the distribution as no distribution gets plotting in the first place. The question now is how to get values of calculated statistics when the distribution is plotted via a function such as mine above. Perhaps a function is not  message so cannot be sent to an object using <<?

Any help would be very useful as I am still learning JMP.

When it's too good to be true, it's neither
Craige_Hales
Super User

Re: Pass items from calculated statistics to specific coordinates in a saved data-table

2 issues, the local variable that is returned is never assigned anything, and the data table needs to be passed to the user function. Something like this

 


dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

getDistChart = Function( {dt, ColName, _LSL, _USL},
	{distChart}, 

	New Window( "" || ColName || " distribution", 

		distChart = dt << Distribution(
			Stack( 1 ),
			Continuous Distribution(
				Column( As Column( ColName ) ),
				Horizontal Layout( 1 ),
				Vertical( 0 ),
				Capability Analysis( LSL( _LSL ), USL( _USL ) )
			),
			SendToReport(
				Dispatch(
					{},
					"Distrib Histogram",
					FrameBox,
					{DispatchSeg( LabelSeg( 1 ), {Font( "Segoe UI", 7, "Plain" )} ),
					DispatchSeg( LabelSeg( 2 ), {Font( "Segoe UI", 7, "Plain" )} )}
				)
			)
		)
	);

	Return( distChart );
);

dist = getDistChart( dt, "weight", 55, 185 );

In JMP, the << operator is the send operator and sends a message (on the right) to a scriptable object, on the left. The data table (dt) is a scriptable object, but it doesn't know about a message getDistChart. It does know about the built in platforms, like distribution. The scripting index shows all the message names for the data table.

 

Craige
Neo
Neo
Level VI

Re: Pass items from calculated statistics to specific coordinates in a saved data-table

Thanks @Craige_Hales. I understand the issue a bit better now. However there is still a glitch. The following works as intended

Names Default To Here (1);

delete symbols ();
clear log ();

// set up a table to accept the results
resultsdt = New Table( "Results Table",
	Add Rows( 8),
	New Column( "Column 1" ),
	New Column( "Column 2" ),
	New Column( "Column 3" ),
	New Column( "Column 4" ),
	New Column( "Column 5" ),
	New Column( "Column 6" ),
	New Column( "Min", Numeric ),
	New Column( "Median", Numeric ),
	New Column( "Max", Numeric ),
	New Column( "SD", Numeric )
);

Column(resultsdt, "Column 1")[1] = "A";
Column(resultsdt, "Column 1")[2] = "B";
Column(resultsdt, "Column 1")[3] = "C";
Column(resultsdt, "Column 1")[4] = "D";
Column(resultsdt, "Column 1")[5] = "E";
Column(resultsdt, "Column 1")[6] = "F";
Column(resultsdt, "Column 1")[7] = "G";
Column(resultsdt, "Column 1")[8] ="H";

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

getDistChart = Function({ColName, _LSL, _USL}, {distChart},

New Window(""||ColName||" distribution",

distChart = dt << Distribution(
	Stack( 1 ),
	Continuous Distribution(
		Column(As Column (ColName) ),
		Horizontal Layout( 1 ),
		Vertical( 0 ),
		Capability Analysis( LSL(_LSL ), USL(_USL) )
	),
	SendToReport(
		Dispatch(
			{},
			"Distrib Histogram",
			FrameBox,
			{DispatchSeg( LabelSeg( 1 ), {Font( "Segoe UI", 7, "Plain" )} ),
			DispatchSeg( LabelSeg( 2 ), {Font( "Segoe UI", 7, "Plain" )} )}
		)
	)
);
);

return(distChart);
);


dist =  getDistChart ("weight", 55, 185);
toPass= Report( dist )[Outline Box("weight" ), Outline Box( "Quantiles" ), Table Box( 1 ), Number Col Box(1)]<< get (1); 
//resultsdt = include ("basicTable.jsl");
resultsdt[1, 2] = toPass;
//show (toPass);

However, if I define resultsdt separately as below

Names Default To Here (1);

// set up a table to accept the results
resultsdt = New Table( "Results Table",
	Add Rows( 8),
	New Column( "Column 1" ),
	New Column( "Column 2" ),
	New Column( "Column 3" ),
	New Column( "Column 4" ),
	New Column( "Column 5" ),
	New Column( "Column 6" ),
	New Column( "Min", Numeric ),
	New Column( "Median", Numeric ),
	New Column( "Max", Numeric ),
	New Column( "SD", Numeric )
);

Column(resultsdt, "Column 1")[1] = "A";
Column(resultsdt, "Column 1")[2] = "B";
Column(resultsdt, "Column 1")[3] = "C";
Column(resultsdt, "Column 1")[4] = "D";
Column(resultsdt, "Column 1")[5] = "E";
Column(resultsdt, "Column 1")[6] = "F";
Column(resultsdt, "Column 1")[7] = "G";
Column(resultsdt, "Column 1")[8] ="H";

and then call it as below (which is how I have got my actual code set up)

Names Default To Here (1);

delete symbols ();
clear log ();


dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

getDistChart = Function({ColName, _LSL, _USL}, {distChart},

New Window(""||ColName||" distribution",

distChart = dt << Distribution(
	Stack( 1 ),
	Continuous Distribution(
		Column(As Column (ColName) ),
		Horizontal Layout( 1 ),
		Vertical( 0 ),
		Capability Analysis( LSL(_LSL ), USL(_USL) )
	),
	SendToReport(
		Dispatch(
			{},
			"Distrib Histogram",
			FrameBox,
			{DispatchSeg( LabelSeg( 1 ), {Font( "Segoe UI", 7, "Plain" )} ),
			DispatchSeg( LabelSeg( 2 ), {Font( "Segoe UI", 7, "Plain" )} )}
		)
	)
);
);

return(distChart);
);


dist =  getDistChart ("weight", 55, 185);
toPass= Report( dist )[Outline Box("weight" ), Outline Box( "Quantiles" ), Table Box( 1 ), Number Col Box(1)]<< get (1); 
resultsdt = include ("basicTable.jsl");
resultsdt[1, 2] = toPass;
//show (toPass);

I get the error

Not subscriptable value{8} in access or evaluation of 'Assign' , resultsdt[1, 2] =  /*###*/toPass/*###*/

where am I going wrong?

(I note that if I do not define the entries in Column 1 at all,  both above approaches work fine)

When it's too good to be true, it's neither
Craige_Hales
Super User

Re: Pass items from calculated statistics to specific coordinates in a saved data-table

 

resultsdt = include ("basicTable.jsl");

If that file is what you show, the problem is resultsdt is not a data table, but (maybe?) whatever this evaluates to

Column(resultsdt, "Column 1")[8] ="H";

which might be "H". The result of the include function is the last thing evaluated. (Consistent with your note.)

 

Yes, the error message was not as helpful as you might wish. @Audrey_Shull  - it should point to the left of the =, not the right.

 

Craige
Neo
Neo
Level VI

Re: Pass items from calculated statistics to specific coordinates in a saved data-table

The statement 

Column(resultsdt, "Column 1")[8] ="H";

just passes a parameter name to the 8th row of column 1. An alternate way of defining resultsdt

Names Default To Here (1);

// set up a table to accept the results
resultsdt = New Table( "Results Table",
	Add Rows( 8),
	New Column( "Column 1" ),
	New Column( "Column 2" ),
	New Column( "Column 3" ),
	New Column( "Column 4" ),
	New Column( "Column 5" ),
	New Column( "Column 6" ),
	New Column( "Min", Numeric ),
	New Column( "Median", Numeric ),
	New Column( "Max", Numeric ),
	New Column( "SD", Numeric )
);
resultsdt:Column 1[1] ="A";
resultsdt:Column 1[2] ="B";
resultsdt:Column 1[3] ="C";
resultsdt:Column 1[4] ="D";
resultsdt:Column 1[5] ="E"; 
resultsdt:Column 1[6] ="F";
resultsdt:Column 1[7] ="G";
resultsdt:Column 1[8] ="H";

also does not work when using 

resultsdt = include ("basicTable.jsl");

However, if I leave the column 1 empty the code runs fine. Any help to resolve this issue would be every useful.

When it's too good to be true, it's neither
Craige_Hales
Super User

Re: Pass items from calculated statistics to specific coordinates in a saved data-table

Look at your code carefully. you are assigning the returned value of the include function to resultsdt. That returned value is the last thing done by the file that is included, which evaluates to "H". it is not a data table.

 

edit:

either (1) add a final line to basicTable.jsl that says

resultsdt;

or (2) change the include like this (adding comment)

/*resultsdt =*/ include ("basicTable.jsl");

I think (1) seems closer to what you expect. It makes sure the last thing evaluated is the variable holding the data table, which then gets returned as the result of include().

(2) will also work, maybe, depending on local behavior and using the same variable name. I think it will be a little unpredictable depending if you use namesDefaultToHere every where and whether resultsdt already exists. Not sure how that will work without testing.

Craige
Neo
Neo
Level VI

Re: Pass items from calculated statistics to specific coordinates in a saved data-table

Thanks. This works. Coming from Matlab and C# I am still getting used to JSL way of thinking.

When it's too good to be true, it's neither