Pass items from calculated statistics to specific coordinates in a saved data-tableI 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)
Data TableGraphicsScriptingRe: Pass items from calculated statistics to specific coordinates in a saved data-tableI 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";Re: Pass items from calculated statistics to specific coordinates in a saved data-tableHi @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
Re: Pass items from calculated statistics to specific coordinates in a saved data-tableThanks @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)
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
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.
Re: Pass items from calculated statistics to specific coordinates in a saved data-tableHi 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: https://community.jmp.com/t5/JSL-Cookbook/Extract-Statistics-from-an-Analysis-into-a-Report/ta-p/41547
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
Re: Pass items from calculated statistics to specific coordinates in a saved data-tableThanks @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?
Re: Pass items from calculated statistics to specific coordinates in a saved data-tableHi @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/
Re: Pass items from calculated statistics to specific coordinates in a saved data-tableThanks 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?
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.