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
datadad2
Level II

convert literal column names to a list of strings

If I have a list of column literal references, how can I convert them to a list of the string names? Can it be done directly without subsetting the columns first?

col_names = {:Column 1, :"Y (%)"n, :"Quotes \!":name\!""n, :group}

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: convert literal column names to a list of strings

Getting the directly in correct format is often the easiest option (like Jim did show). You can also convert the list for example by using Transform Each and << Get Name.

Names Default To Here(1);
dt = New Table("Untitled",
	Add Rows(0),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("Y (%)", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("Quotes \!":name\!"", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("group", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);
col_names = {:Column 1, :"Y (%)"n, :"Quotes \!":name\!""n, :group};

col_names_str = Transform Each({col_name}, col_names, col_name << get name);
-Jarmo

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: convert literal column names to a list of strings

If the 4 column names you are specifying are the complete list of columns in the data table, the easiest way to turn them into a list is

col_names = current data table() << get column names( string );

The "string" argument tells the function to place each column name into the list as a literal string.  

See the Scripting Index for a more complete list of arguments and examples

Jim
datadad2
Level II

Re: convert literal column names to a list of strings

Agree, this would be a nice option if we subset those columns into a private temp table say

jthi
Super User

Re: convert literal column names to a list of strings

Getting the directly in correct format is often the easiest option (like Jim did show). You can also convert the list for example by using Transform Each and << Get Name.

Names Default To Here(1);
dt = New Table("Untitled",
	Add Rows(0),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("Y (%)", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("Quotes \!":name\!"", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("group", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);
col_names = {:Column 1, :"Y (%)"n, :"Quotes \!":name\!""n, :group};

col_names_str = Transform Each({col_name}, col_names, col_name << get name);
-Jarmo