Subscribe Bookmark RSS Feed

Can I save scripts that reflect changes that are made to rows during an analysis? For instance, if I have one data table and I save a t-test script to it, but then I exclude some rows and run a second t-test script, can the two scripts turn the rows on an

redrooster

Community Member

Joined:

Dec 5, 2014

Can I save scripts that reflect changes that are made to rows during an analysis? For instance, if I have one data table and I save a t-test script to it, but then I exclude some rows and run a second t-test script, can the two scripts turn the rows on and off as needed within the same data table?

2 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

This can be accomplished by saving the rowstates used for the first t-test into a column and then running the t-test and save the t-test script.  Then make your excludes and save the new rowstates to another new column and then run and save the new t-test script. 

To create a rowstate column to store the rowstates in, simply create a new column, but instead of making it a numeric or character column, select "Rowstate".

Then make all of the excludes, colors, selections, etc. you want.  Then go to the columns panel and rt mouse click on the newly created rowstate column and select "Copy from rowstates".

At this point, you will have to manually copy the rowstate column values back to the rowstates, before running which ever of the scripts you want to run. To automate this procedure for the scripts, you simply would have to edit the script you saved, and add the following to the top of the script:

column name of the rowstate column that contains the exclusions you want for this t-test << copy to rowstates;

This will change the rowstates back to the state they were in when you saved them to the new rowstate column.

Jim
ian_jmp

Staff

Joined:

Jun 23, 2011

Just to add a little to Jim's reply, you can try this code. Do 'File > New > New Script', cut and paste this into the window that appears, then 'Edit > Run Script'. Watch the report update as the saved row states are applied.

NamesDefaultToHere(1);

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

// Make columns to persist row states

s1 = dt << NewColumn("State 1", Rowstate);

s2 = dt << NewColumn("State 2", Rowstate);

// Populate these columns

dt << selectRandomly(0.5);

dt << hideAndExclude;

dt << clearSelect;

s1 << copyFromRowStates(s1);

dt << clearRowStates;

dt << selectRandomly(0.5);

dt << hideAndExclude;

dt << clearSelect;

s2 << copyFromRowStates(s2);

dt << clearRowStates;

// Use the saved row states (use 'Automatic Recalc' to make the report respond)

dt << Oneway( Y( :height ), X( :sex ), t Test( 1 ), Mean Diamonds( 1 ), Automatic Recalc( 1 ) );

Wait(3);

s1 << copyToRowStates;

Wait(3);

dt << clearRowStates;

s2 << copyToRowStates;

Wait(3);

dt << clearRowStates;