Subscribe Bookmark RSS Feed

Table Transformation/Creation

switzal87

Community Trekker

Joined:

May 21, 2015

What is the fastest way to transform Table 1 to Table 2? I appreciate if you can elaborate the steps. Im a newbie in JMP.

9428_Jmp2_coulumns.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

What is the transformation you are using to create Table 2?  It looks like you may be repeating rows A and B, but it is unclear to me how you get the rows labeled C in Table 2.

To achieve the repeated rows, one way to do this is by using the Concatenate function, and then concatenate Table 1 to its self 4 times, and then sort by the first column.  An example script is below.  This may be achieved without scripting by using the Concatenate and Sort functions from the Table menu.

// Example

Names Default To Here( 1 );

// Create table1.

table1 = New Table( "Table 1",

      Add Rows( 3 ),

      New Column( "Table 1", Character, Nominal, Set Values( {"A", "B", "C"} ) ),

      New Column( "X", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1, 2, 2] ) ),

      New Column( "Y", Numeric, Continuous, Format( "Best", 12 ), Set Values( [2, 2, 2] ) ),

      New Column( "Z", Numeric, Continuous, Format( "Best", 12 ), Set Values( [3, 1, 1] ) )

);

nn = 4; // Times to repeat table1.

tt = Repeat( List( table1 ), nn ); // Create repeat reference.

table2 = table1 << Concatenate( tt, Output Table Name( "Table 2" ) ); // Create table2.

Column( table2, "Table 1" ) << Set Name( "Table 2" ); // Change column name.

table2 << Sort( By( :Table 2 ), Order( Ascending ), Replace Table ); // Sort table 2.

1 REPLY
Solution

What is the transformation you are using to create Table 2?  It looks like you may be repeating rows A and B, but it is unclear to me how you get the rows labeled C in Table 2.

To achieve the repeated rows, one way to do this is by using the Concatenate function, and then concatenate Table 1 to its self 4 times, and then sort by the first column.  An example script is below.  This may be achieved without scripting by using the Concatenate and Sort functions from the Table menu.

// Example

Names Default To Here( 1 );

// Create table1.

table1 = New Table( "Table 1",

      Add Rows( 3 ),

      New Column( "Table 1", Character, Nominal, Set Values( {"A", "B", "C"} ) ),

      New Column( "X", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1, 2, 2] ) ),

      New Column( "Y", Numeric, Continuous, Format( "Best", 12 ), Set Values( [2, 2, 2] ) ),

      New Column( "Z", Numeric, Continuous, Format( "Best", 12 ), Set Values( [3, 1, 1] ) )

);

nn = 4; // Times to repeat table1.

tt = Repeat( List( table1 ), nn ); // Create repeat reference.

table2 = table1 << Concatenate( tt, Output Table Name( "Table 2" ) ); // Create table2.

Column( table2, "Table 1" ) << Set Name( "Table 2" ); // Change column name.

table2 << Sort( By( :Table 2 ), Order( Ascending ), Replace Table ); // Sort table 2.