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
bhdarst
Level I

Concatenate function overwriting rows?

I'm writing part of a script to update a table by appending new rows onto it using the "Concatenate" function. However every time I try concatenating with a particular set of 7 rows, the script somehow overwrites the first seven rows in the original table with the new seven, then adds the new seven rows to the bottom as well. There are no identical values between the new and replaced rows in any of the table columns.

 

Does anyone know what could be happening here? Is there a part of the Concatenate function that I could be overlooking?

 

Thanks a lot,

Brian D.

4 REPLIES 4
Highlighted

Re: Concatenate function overwriting rows?

Is it possible that your code does something like this:

 

dt1 = Data Table( "old rows" );
dt2 = Data Table( "new rows" );

dt3 = dt2 << Concatentate( dt2, ... );

That is, does the code inadvertently concatenate the same data table to itself?

Learn it once, use it forever!
Highlighted
pauldeen
Level IV

Re: Concatenate function overwriting rows?

If you give us your code we can help you a lot better.
Highlighted
bhdarst
Level I

Re: Concatenate function overwriting rows?

Thanks for the reply. I don't believe so... I have a table I am updating ("FPKM by gene running") and a new one ("New genes FPKM by ferm & strain") that my script generates. The Update and Concatenate portion of my script is as follows:

 

dt5 = Data Table( "New genes FPKM by ferm & strain" );
dt6 = Data Table( "FPKM by gene running" );

dt6 << Update( With( dt5)));

dt6 << Concatenate( dt5, append to first table);

I am using the Concatenate function as well as Update because apparently Update will add new columns, but not new rows? Ideally I'd like to add columns AND rows to the "FPKM by gene running" table, and only ones that were not previously present. Apologies as I am new to JSL.

Highlighted
txnelson
Super User

Re: Concatenate function overwriting rows?

Your described results of your code, is exactly as I would expect JMP to do.  As specified

dt6 << Update( With( dt5)));

will take row 1 from data table dt5 and write it on top of row 1 from data table dt6. And will continue writing row 2 from dt5 on top of row 2 in dt6, etc. until the last row of which ever data table has the shortest number of rows.

Then the statement

dt6 << Concatenate( dt5, append to first table);

will add new rows to the bottom of data table dt6, one new row for each row in dt5, adding in new columns to the dt6 data table that are in dt5 that were not in dt6.

What I believe you want to do, is to use a 

     Tables==>Join

Which can add both new rows and new columns to your data table.  It does this by creating a new table, but it is a very easy task, that once the new table is created, to delete the old dt6 and rename the new table to dt6's name.

Jim
Article Labels

    There are no labels assigned to this post.