Turn on suggestions

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

Showing results for

- JMP User Community
- :
- Discussions
- :
- Re: Replacing Matrix Values

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

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

Re: Replacing Matrix Values

So once you have the data into the matrices, how do you move them to the permanent locations?

Jim

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

Re: Replacing Matrix Values

Thank you for your help and interest. Mark Bailey's associative array method has worked. Now I am trying to figure out how to put the associative array into a data table so I can export it as a CSV file.

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

Re: Replacing Matrix Values

I may be a bit redundant, but here is an alternative way of handling this given the requirement to output to a csv file. It uses data table manipulation to get the data into the correct form, and then writes the data table to a csv file

```
Names Default To Here( 1 );
// Create some sample data
dt = New Table( "Example",
add rows( 72 ),
New Column( "c1", formula( Random Uniform( 1, 500 ) ) ),
New Column( "c2", formula( Random Uniform( 1, 500 ) ) ),
New Column( "c3", formula( Random Uniform( 1, 500 ) ) )
);
dt << run formulas;
dt:c1 << delete property( "formula" );
dt:c2 << delete property( "formula" );
dt:c3 << delete property( "formula" );
// Get the list of columns
colNamesList = dt << get column names( string, numeric );
// Loop across the columns and process them
For( i = 1, i <= N Cols( dt ), i++,
// Create a new table will only the single column
dtTemp = dt << subset(invisible, selected rows( 0 ), columns( Column( colNamesList[i] ) ) );
// If there are not 96 rows, add them
If( N Rows( dtTemp ) < 96,
rowCount = N Rows( dt );
dtTemp << add rows( 96 - rowCount );
For( k = rowCount + 1, K <= 96, k++,
Column( dtTemp, colNamesList[i] )[k] = 0
);
);
// Create a sequence column to allow for proper splitting of the data
dtTemp << New Column( "sequence",
formula(
x = Mod( Row(), 8 );
If( x == 0, x = 8 );
x;
)
);
dtTemp << run formulas;
// Split the data into 8 columns.....if this should be 12 just change the sequence formula above
dtSplit = dtTemp << Split(invisible, Split By( :sequence ), Split( Column( dtTemp, colNamesList[i] ) ), Sort by Column Property );
dtSplit << run formulas;
// Close the un needed temporary data table
Close( dtTemp, nosave );
// Change the output preferences to get rid of headers
current_pref = Char( Arg( Parse( (Char( Get Preferences( Export settings ) )) ), 1 ) );
// Set prefs (comma delimited, no headers)
Pref( Export Settings( End Of Field( Comma ), Export Table Headers( 0 ) ) );
// Save csv file
dtSplit << save( "$TEMP\" || colNamesList[i] || ".csv" );
//Restore oribinal prefs
Eval( Parse( "pref(" || current_pref || ")" ) );
// Close the un necessary table
Close( dtSplit, nosave );
);
```

Jim

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

Re: Replacing Matrix Values

Please take a look at this post. You might find it useful in your work with experiments on plates.

Learn it once, use it forever!

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

Re: Replacing Matrix Values

I suspect that as a new JMP user, your mindset might still be that of a spreadsheet user. I do not know the destination of the CSV file, but you can do much in JMP using a tall table layout.

Why do you need the 8x12 layout? Why do you need to export the matrices as CSV files?

We might be able to help you use JMP to your advantage if we knew where this analysis was going.

Learn it once, use it forever!

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

Re: Replacing Matrix Values

I need the layout for my setup and a csv file is the only type of file read by the device

Highlighted
##

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

Re: Replacing Matrix Values

See Help > Scripting Index. Click the drop down button and select Functions. Search for As Table() function.

Learn it once, use it forever!

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

Re: Replacing Matrix Values

Ok, this updated version of the script should do the trick:

```
Names Default to Here( 1 );
dt = Open( "Example.jmp" );
table = Associative Array();
For( c = 1, c <= N Col( dt ), c++,
data = Column( dt, c ) << Get As Matrix;
If( N Row( data ) < 96,
data |/= J( 96 - N Row( data ), 1, 0 );
);
table[Column( dt, c ) << Get Name] = Transpose( Shape( data, 12, 8 ) );
);
content = table << Get Contents;
For( t = 1, t <= N Items( content ), t++,
dt = As Table( content[t][2] );
Close( dt, Save( content[t][1] || ".CSV" ) );
);
```

Unfortunately, I do not know how to suppress the first line with the header names in the CSV files. Perhaps someone else knows. We could immediately read the file back as text, delete the first line, and save it out again.

Learn it once, use it forever!

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

Re: Replacing Matrix Values

This worked!! However, I actually wanted to keep the the column names( or in this case content[t][1]) in the csv file as the first line. It currently does not show. Do you know how I can keep it in the first cell of the csv file?

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

Re: Replacing Matrix Values

Please be patient. I am having difficulty with saving the CSV file for some unknown reason. I am working with Technical Support.

While I wait for them to reply, I want to be sure that you want to replace the first row of the CSV file (original data column headers) with just the name of the original data column name.

Learn it once, use it forever!