OK, so I have begun familiarizing with JMP and worked successfully on my first script to extract, rearrange and format a data table from a database. Works fine and saves time. As I have developed this script with a copy of Jump into JMP Scripting on my lap, I was naturally interested in understanding the script. So here comes the issue.
Think of a manufacturing process requiring lots of different measurements. The database has all test methods in one column and all test results in another column. To get what I want I need to split this table. However, since a lot of what we have in the database is from legacy Excel files, some recoding of the column holding the test names is required due to earlier, erroneous entries. To get to that piece of (re)code I went via Recode... in the Columns menu, and it is the only piece in the script I cannot understand. (It's generally a very basic script.)
In the example posted below, the capital letters and numbers reflect variations of the name of the actual test method used. For example, A is one test (say pH testing), B is another test (e.g. viscosity). A(1), A(2), ... A(n) would all be recoded to A, then B(1), ... B(n) to B, and so on. Now how does the software now from exactly this piece of code which variables belong together? I checked the scripting guide and the scripting index but still don't understand. _rcOrig and _rcNow, what do they mean? The script, i.e. rows & columns are arranged exactly as they are in my copy of the complete script.
Thanks for an answer.
dt << Recode Column(
dt:TestName,
{Map Value(
_rcOrig,
{"A(1)", "A(2)",
"A(3)", "A(4)",
"A(5)", "A(6)", "B(1)",
"B(2)", "C(1)", "C(2)",
"C(3)", "C(4)", "D(1)", "D(2)", "E(1)",
"E(2)", "F(1)", "F(2)", "G(1)", "G(2)",
"H(1)", "H(2)", "I(1)", "I(2)",
"I(3)", "I(4)", "J(1)", "J(2)", "K(1)",
"K(2)", "L(1)", "L(2)",
"M(1)", "M(2)", "M(3)",
"M(4)"},
Unmatched( _rcNow )
)},
Target Column( col1 )
);
dt << End Data Update;I created a new column in a data table with the test values you had in the JSL you provided.

I then opened the Recode dialog and made the recode changes.

I then went to the red triangle and selected
Script=>Save to Script Window
and below is what it gave me.
Names Default To Here( 1 );
dt = Data Table( "Big Class" );
dt << Begin Data Update;
col1 = dt << New Column( dt:test );
col1 << Set Name( "test 2" );
dt << Move Selected Columns( {col1}, after( dt:test ) );
dt << Recode Column(
dt:test,
{Map Value(
_rcOrig,
{"A(1)", "A", "A(2)", "A", "A(3)", "A", "A(4)", "A", "A(5)", "A", "A(6)",
"A", "B(1)", "B", "B(2)", "B", "C(1)", "C", "C(2)", "C", "C(3)", "C", "C(4)",
"C", "D(1)", "D", "D(2)", "D", "E(1)", "E", "E(2)", "E", "F(1)", "F", "F(2)",
"F", "G(1)", "G", "G(2)", "G", "H(1)", "H", "H(2)", "H", "I(1)", "I", "I(2)",
"I", "I(3)", "I", "I(4)", "I", "J(1)", "J", "J(2)", "J", "K(1)", "K", "K(2)",
"K", "L(1)", "L", "L(2)", "L", "M(1)", "M", "M(2)", "M", "M(3)", "M", "M(4)",
"M"},
Unmatched( _rcNow )
)},
Target Column( col1 )
);
dt << End Data Update;
In the example, you can see how the values are set for each of the value/result pairs
Hi,
If its always one Letter, you may want to make a simple formula like this:
dt << New Column( "Test_Name", formula( Left(:TestName, 1)));