cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Samuel11
Level I

Converting multiple columns into one column just like the picture.

I need help with this table. 
I am trying to rotate part of the table.
the table has about 300 columns and 30 rows. 

I want to keep row 12 to 30 the same way they are till column 11.
and rotate the rest of the columns (from 12 to the end.) so they be just  like the picture.

I think the solution will be that : each row from 12 to 30 will have 288 columns.
See picture for the idea of what I want. 
If you can send a Code that would be great. 

the first picture shows the actual table.
the second picture shows the solution I want.
JMP-Task-1 regular table.pngJMP-Task-1 solution table.png

3 REPLIES 3
txnelson
Super User

Re: Converting multiple columns into one column just like the picture.

First off, your original data table is an inappropriate structure for a JMP table.  JMP is not a spreadsheet.  It is an analytical column based data table.  And the JMP statistical and graphical platforms assume the Analytical data table form.  Thus, attempting to transpose your columns and rows within your data table you will not be able to use the 

     Tables==>Transpose

platform.

Additionally, you will not be able to directly use many of the JSL mathematical functions, since in order for you to have the table structured the way you have it, all of the columns, and thus all of the individual cells will be of data type Character, not Numeric.  If data contained in row 12 and beyond were in a JMP data table, it would be a simple matter to use

     Tables==>Split

to change the data into the form you want.

But even given that, you could write a piece of JSL that will transpose the subarea within the data table, into a new format.  The JMP data table can be referenced as a row by column matrix, and given that, a program can be written that takes the value from datatable("1911-15 V1 500")[5,14] and place that value into any other row/column cell desired.  This can be put into a For() looping structure to make the code more complex, but the point is, in my opinion a piece of JSL will have to be written to do the transposition. 

Jim
Samuel11
Level I

Re: Converting multiple columns into one column just like the picture.

Samuel11_0-1579732387440.png

this is the actual file, could you explain how would I be able to split the table and link them again?

txnelson
Super User

Re: Converting multiple columns into one column just like the picture.

Here is a script that works on the sample data table you provided.  BTW, it would be more convenient if you had attached a copy of the data table, rather than having to manually create it manually.  Out side of that, I believe the script will work as long as the first 11 columns remain static, the data starts on row 3, and all of the columns after column 11 are considered columns to be processed.

names default to here(1);
dt=current data table();

// Find the number of columns to process
numberOfMeasurements = N Cols(dt) - 11;

// Add the 3 new columns to place the measurements into
dt << Add Multiple Columns( "Rotated", 3,After(:column 11), Character  );

// Add in the number of empty rows required for all of the rotations
For(i=N Rows(dt),i>=3, i--,
	dt << Add Rows( numberOfMeasurements - 1, after(i) ); 
);

// Move the data into the required new cells
For( theRow = 3, theRow <= N Rows(dt), theRow = theRow + numberOfMeasurements,
	For( theCol = 12 + 3, theCol <= N Cols(dt), theCol++,
		:Rotated 1[theRow + theCol-12-3] = column(theCol)[1]; 
		:Rotated 2[theRow + theCol-12-3] = column(theCol)[2];
		:Rotated 3[theRow + theCol-12-3] = 
			column(theCol)[theRow];
	)
);

All of the functions used are documented in the Scripting Index

     Help==>Scripting Index

Finally, I am providing this script under the assumption that you are new to JMP and therefore as an illustration that JMP JSL can do just about anything you need to do.  The community forum is not a place to request individuals to write code for you.  It is a group whos purpose is to help JMP users who are having issues.  It is assumed that members who as questions are there to learn JMP, so that in the future, they will become more proficient and more independent users of JMP.

Jim