cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
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
2 ACCEPTED SOLUTIONS

Accepted Solutions
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

View solution in original post

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

View solution in original post

16 REPLIES 16
jthi
Super User

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

I think data table subscripting can help you with this

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt[10,3] = "AAAAAAAAAAAAAA";
-Jarmo
ron_horne
Super User (Alumni)

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

Hi @Neo 

see if you can extract what you need from this script

Names Default To Here( 1 );

// set up a table to accept the results
resultsdt = New Table( "Results Table",
	Add Rows( 20 ),
	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 )
);

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


// Launch platform: Distribution
output = Report( dist = dt << Distribution( Continuous Distribution( Column( :height ) ) ) );

// Extract min median max and SD
resultsdt[5, 7] = output[Outline Box( "height" ), Outline Box( "Quantiles" ), Table Box( 1 ), Number Col Box( 1 )] << get( 11 ); // min
resultsdt[5, 8] = output[Outline Box( "height" ), Outline Box( "Quantiles" ), Table Box( 1 ), Number Col Box( 1 )] << get( 6 ); // median
resultsdt[5, 9] = output[Outline Box( "height" ), Outline Box( "Quantiles" ), Table Box( 1 ), Number Col Box( 1 )] << get( 1 ); // max
resultsdt[5, 10] = output[Outline Box( "height" ), Outline Box( "Summary Statistics" ), Number Col Box( 1 )] << get( 2 ); // Std dev.

when it comes to extracting numbers out of output one needs to be careful. Correct references to locations may change if the output is different because of preferences or just includes multiple outputs in one window. 

let us know if it works.

ron

 

 

Neo
Neo
Level VI

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

Thanks @ron_horne. I think this would work. However, before trying this out on my actual problem, I have got one question. Does "Results Table" need to open before the values could be passed on to it?

In my case, the "Results Table" is a saved file and I was not planning to open it unless it is not possible to pass values on to it otherwise.

(I will need to change the rest of my code if I need to have my "Results Table" open at the instance when values are passed on to it) 

When it's too good to be true, it's neither
ron_horne
Super User (Alumni)

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

 

Hi @Neo 

To the best of my knowledge there is no way in JMP to set data into a cell of a closed table.

If anyone else here knows better please let us know.

perhaps you can open another table as an intermediary to keep the information there while you are still collecting and only at the end open the final result table.

 

ron

 

Neo
Neo
Level VI

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

@ron_horne . Thanks. It took me some time to recode so that I can have "Results Table" open for values from calculated statistics could be passed on to it.

I have started with you suggestion and have god a question. Why does this not work?

distb =  Distribution( Continuous Distribution( Column( :height ) ) ) ;

// Extract min median max and SD
resultsdt[5, 7] = distb[Outline Box( "height" ), Outline Box( "Quantiles" ), Table Box( 1 ), Number Col Box( 1 )] << get( 11 ); // min
resultsdt[5, 8] = distb[Outline Box( "height" ), Outline Box( "Quantiles" ), Table Box( 1 ), Number Col Box( 1 )] << get( 6 ); // median
resultsdt[5, 9] = distb[Outline Box( "height" ), Outline Box( "Quantiles" ), Table Box( 1 ), Number Col Box( 1 )] << get( 1 ); // max
resultsdt[5, 10] = distb[Outline Box( "height" ), Outline Box( "Summary Statistics" ), Number Col Box( 1 )] << get( 2 ); // Std dev.

and why does it have to be?

output = Report( dist = dt << Distribution( Continuous Distribution( Column( :height ) ) ) );

I have got multiple distribution plots which I can easily assign a name such as distb1, distb2,... but if do I need have

output = Report( dist = dt << Distribution( ..... ) );

I will need to check how this affects the rest of my code.

When it's too good to be true, it's neither
ron_horne
Super User (Alumni)

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

Hi Neo,

your reference to distb is not working sine distb is not a report layer of anything. it is the analysis layer. In JMP there is a difference between them.

in order to extract anything from the output you need to reference the report layer explicitly.

see this: Extract Statistics from an Analysis into a Report if you have multiple outputs you will need to name and define them correctly to be sure you are getting the values you are aiming at.

let us know if it works. otherwise, consider providing some files and scrips from the point that is giving you issues.

all the best,

ron

 

Neo
Neo
Level VI

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

Thanks @ron_horne. Let me try to give an overview of what I am trying to do. My main script has the following (simplified here) flow.

Open a data table (and call it dt), and then plot distribution plots for several columns in it using a function 

getDistribution ("ColName", "LSL", "USL", "other input parameters")

Each resulting distribution plots have "Quantiles", "Summary Statistics" and "Capability Analysis (with outline closed)".

Next part of main script is to create a table (lets call it resultsdt) with several rows and columns where I need to pass values of calculated statistics as indicated in the original post.

However, the following does not work.

output = Report( dist = dt << getDistribution("ColName", "LSL", "USL", "other input parameters") );

resultsdt[5, 9] = Output[Outline Box( "height" ), Outline Box( "Quantiles" ), Table Box( 6 ), Number Col Box( 11)] << get( 1 ); // max

I have made sure that the numbers in Table Box () and Number Col Box () are correct. I get the following error

Send Expects Scriptable Object{8} in access or evaluation of 'Send' , output[Outline Box( "height" ), Outline Box( "Quantiles" ),
Table Box( 6 ), Number Col Box( 11 )] <<  /*###*/get( 1 ) /*###*/

Where am I going wrong?

 

When it's too good to be true, it's neither
ron_horne
Super User (Alumni)

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

Hi @Neo ,

if i understand your issue correctly you need to pay attention to the numbering and addresses. once you use names of outline boxes the numbering of Table Boxs and Number Col Boxs starts from 1.

Therefore, try the following:

 

resultsdt[5, 9] = Output[Outline Box( "height" ), Outline Box( "Quantiles" ), Table Box( 1 ), Number Col Box( 1)] << get( 1 ); // max

if you want to use Number Col Box (11) try this:

resultsdt[5, 9] = Output[Number Col Box( 11)] << get( 1 ); // max

hope this now works.

generally, there are much fancier ways of getting the script to find the location of the values of interest using xpath () or pattern matching as in this link: http://www.pega-analytics.co.uk/blog/oneway-advisor-step-3/ 

 

 

 

Neo
Neo
Level VI

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

Thanks again @ron_horne , but both these do not work and gives me the same error.

 

Are you saying that the following is correct and valid usage? Note it is not plotting the distribution if used like below (btw I do not understand the function of dist in dist=dt ?) 

Output = Report( dist = dt << getDistribution("ColName", "LSL", "USL", "other input parameters") );

and the error (copied from log)

Send Expects Scriptable Object{8} in access or evaluation of 'Send' , Output[Outline Box( "height" ), Outline Box( "Quantiles" ),
Table Box( 1 ), Number Col Box( 1 )] <<  /*###*/get( 1 ) /*###*/Not subscriptable value{8} in access or evaluation of 'Assign' , resultsdt[5, 9] =  /*###*/Output[Outline Box( "Pass Distribution" ),
Outline Box( "Quantiles" ), Table Box( 1 ), Number Col Box( 1 )] <<  /*###*/get( 1 ) /*###*/
/*###*/

I am getting is due to my following statement (even when your suggestion below)

resultsdt[5, 9] = Output[Outline Box( "height" ), Outline Box( "Quantiles" ), Table Box( 1 ), Number Col Box( 1)] << get( 1 ); // max

If, yes, I would like to do a simple test and pass something more straightforward to resultsdt. Is there a simple test I can do to test if I can get anything at all from Output to the data-table resultsdt?

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