cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Lea_JMP
Level I

Script to subset columns and rename them in the new file

Hello!

 

I am trying to make a script combining the 2 actions of creating a subset Table and renaming column name of the subset at the same time.

 

I have a "Main" table and would like to create 2 subsets from it. One subset "Subset 1" with some of the columns, the other one "Subset 2" with some other columns.

This part of the script is working well but I can't get it right to rename the columns in Subset 1 and Subset 2 without having to run another script. 

 

Could you please help ? Thank you !

 

Data Table( "MAIN" ) <<
Subset(
	Output Table( "Subset 1" ),
	Linked,
	Suppress formula evaluation( 0 ),
	All rows,
	columns(
		:"Time 1"n, :"Parameter 1"n
	)
);

Data Table( "MAIN" ) <<
Subset(
	Output Table( "Subset 2" ),
	Linked,
	Suppress formula evaluation( 0 ),
	All rows,
	columns(
		:"Time 2"n, :"Parameter 2"n
	)
);

dt1 = Open("Subset 1.jmp");
:"Time 1" << Set Name("Time");


dt2 = Open("Subset 2.jmp");
:"Time 2" << Set Name("Time");
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Script to subset columns and rename them in the new file

I think you might not be able to rename them as you have linked subsets

Names Default To Here(1);

dt_main = New Table("Untitled",
	Add Rows(1),
	Compress File When Saved(1),
	New Column("Time 1", Numeric, "Continuous", Format("Best", 12), Set Values([1])),
	New Column("Parameter 1", Numeric, "Continuous", Format("Best", 12), Set Values([1])),
	New Column("Time 2", Numeric, "Continuous", Format("Best", 12), Set Values([2])),
	New Column("Parameter 2", Numeric, "Continuous", Format("Best", 12), Set Values([2]))
);

dt_subset1 = dt_main << Subset(
	Output Table("Subset 1"),
	Linked,
	Suppress formula evaluation(0),
	All rows,
	columns(:"Time 1"n, :"Parameter 1"n)
);

dt_subset2 = dt_main << Subset(
	Output Table("Subset 2"),
//	Linked,
	Suppress formula evaluation(0),
	All rows,
	columns(:"Time 2"n, :"Parameter 2"n)
);


dt_subset1:"Time 1" << Set Name("Time");
dt_subset2:"Time 2" << Set Name("Time");

In this example you can see that Time 2 gets renamed to Time but Time 1 doesn't. Also depending on your starting data and what you wish to do in the end, some stack/split combination could be useful here.

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Script to subset columns and rename them in the new file

I think you might not be able to rename them as you have linked subsets

Names Default To Here(1);

dt_main = New Table("Untitled",
	Add Rows(1),
	Compress File When Saved(1),
	New Column("Time 1", Numeric, "Continuous", Format("Best", 12), Set Values([1])),
	New Column("Parameter 1", Numeric, "Continuous", Format("Best", 12), Set Values([1])),
	New Column("Time 2", Numeric, "Continuous", Format("Best", 12), Set Values([2])),
	New Column("Parameter 2", Numeric, "Continuous", Format("Best", 12), Set Values([2]))
);

dt_subset1 = dt_main << Subset(
	Output Table("Subset 1"),
	Linked,
	Suppress formula evaluation(0),
	All rows,
	columns(:"Time 1"n, :"Parameter 1"n)
);

dt_subset2 = dt_main << Subset(
	Output Table("Subset 2"),
//	Linked,
	Suppress formula evaluation(0),
	All rows,
	columns(:"Time 2"n, :"Parameter 2"n)
);


dt_subset1:"Time 1" << Set Name("Time");
dt_subset2:"Time 2" << Set Name("Time");

In this example you can see that Time 2 gets renamed to Time but Time 1 doesn't. Also depending on your starting data and what you wish to do in the end, some stack/split combination could be useful here.

-Jarmo
Lea_JMP
Level I

Re: Script to subset columns and rename them in the new file

Hi ! 

Thank you very much !

 

It worked well removing the linked data.