Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
reallyneedhelp
Level III

Should I really use a matrix or just use data table for this JSL question?

According to this is the data table given below:

 RowABCD
1A10.020.8-0.6
2B0.0210.7-0.02
3C0.80.710.51
4D-0.6-0.020.511


I'm supposed to create another data table that gives the following: Corresponding Row, Corresponding Column as given in Column 1 and its value. May I ask if I should create a matrix or just do need to edit from the data table? Any help is appreciated, thank you. (Below is a result from the first data table above, except that I have to do it for 2,000+ rows now.)

 

 Corresponding RowsCorresponding Columns>=0.05 && < 1
1AC0.8
2BC0.7
3CA0.8
4CB0.51
5CD0.51
6DC0.51
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
ron_horne
Super User

Re: Should I really use a matrix or just use data table for this JSL question?

Hi @reallyneedhelp ,

let me know if the following scripts brings you any closer to your target.

 

 

dt = current data table ();
cols = dt << Get Column Names( Continuous );
dt << Stack(
	columns( cols ),
	Source Label Column( "Column" ),
	Stacked Data Column( "Data" )
);

Ron

View solution in original post

5 REPLIES 5
Highlighted
ron_horne
Super User

Re: Should I really use a matrix or just use data table for this JSL question?

Hi @reallyneedhelp,

perhaps this quick Stack option will do the Job.

go to Tables>>stack. from there you can follow the pictures

222.png

 

111.png

 

you can also follow this script. once you have the table run the "Stack" script from the top left hand side.

New Table( "Untitled",
	Add Rows( 4 ),
	New Script(
		"Stack",
		Data Table( "Untitled" ) << Stack(
			columns( :A, :B, :C, :D ),
			Source Label Column( "Column" ),
			Stacked Data Column( "Data" )
		)
	),
	New Column( "Row", Character, Nominal, Set Values( {"A", "B", "C", "D"} ) ),
	New Column( "A",
		Numeric,
		Continuous,
		Format( "Best", 12 ),
		Set Values( [1, 0.02, 0.8, -0.6] )
	),
	New Column( "B",
		Numeric,
		Continuous,
		Format( "Best", 12 ),
		Set Values( [0.02, 1, 0.7, -0.02] )
	),
	New Column( "C",
		Numeric,
		Continuous,
		Format( "Best", 12 ),
		Set Values( [0.8, 0.7, 1, 0.51] )
	),
	New Column( "D",
		Numeric,
		Continuous,
		Format( "Best", 12 ),
		Set Values( [-0.6, -0.02, 0.51, 1] )
	)
)

let us know if this is what you are looking for.

Ron

 

 

 

 

 

Highlighted
reallyneedhelp
Level III

Re: Should I really use a matrix or just use data table for this JSL question?

Hi @ron_horne,

Actually, I'm looking for a script that allows me to run the data table without manually having to input the columns and rows individually respectively, like a "for" loop for example (as I said, there will be about 2,000+ rows and columns that I'll be working with), and also, to create another data table that gives the following: Corresponding Row, Corresponding Column as given in Column 1 and its value. So just perhaps, do u have any solution or steps that I can follow? Thank you.

James
Highlighted
ron_horne
Super User

Re: Should I really use a matrix or just use data table for this JSL question?

Hi @reallyneedhelp ,

let me know if the following scripts brings you any closer to your target.

 

 

dt = current data table ();
cols = dt << Get Column Names( Continuous );
dt << Stack(
	columns( cols ),
	Source Label Column( "Column" ),
	Stacked Data Column( "Data" )
);

Ron

View solution in original post

Highlighted
reallyneedhelp
Level III

Re: Should I really use a matrix or just use data table for this JSL question?

Hi @ron_horne,

Thank you so much, I think I got the answer, this is what I did:

dt = Current Data Table();

cols = dt << get column names (continuous);

dtSub = dt << Stack( columns( cols ), Source Label Column( "Label" ), Stacked Data Column( "Data" ), Output Table Name ("Sift Out") );
dtSub << select where (1> :Data & :Data >= 0.5);
dtSubSub = dtSub << subset ( Output Table Name ("Required"));

Thank you once again! :)
Highlighted
txnelson
Super User

Re: Should I really use a matrix or just use data table for this JSL question?

Building on @ron_horne example, here is a complete piece of code that will work on the sample data table, or on the 2000x2000 data table you mentioned

dt = current data table ();
cols = dt << Get Column Names( Continuous );
dtStack = dt << Stack(
	columns( cols ),
	Source Label Column( "Coresponding Columns" ),
	Stacked Data Column( ">=0.05&&<1" )
);
dtStack:Row << set name("Corresponding Rows");

dtStack << select where( dtStack:Name(">=0.05&&<1") < .05 | dtStack:Name(">=0.05&&<1")>=1);
dtStack << delete rows;
Jim
Article Labels

    There are no labels assigned to this post.