Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- Should I really use a matrix or just use data table for this JSL question?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jun 16, 2019 1:22 AM
(3686 views)

According to this is the data table given below:

Row | A | B | C | D | |

1 | A | 1 | 0.02 | 0.8 | -0.6 |

2 | B | 0.02 | 1 | 0.7 | -0.02 |

3 | C | 0.8 | 0.7 | 1 | 0.51 |

4 | D | -0.6 | -0.02 | 0.51 | 1 |

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 Rows | Corresponding Columns | >=0.05 && < 1 | |

1 | A | C | 0.8 |

2 | B | C | 0.7 |

3 | C | A | 0.8 |

4 | C | B | 0.51 |

5 | C | D | 0.51 |

6 | D | C | 0.51 |

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

5 REPLIES 5

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

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
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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! :)

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
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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.