new column with initial data values<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hi
Does anyone know how to script the creation of a new column with initial data values?
Below is my best guess, but it doesn't work. Cannot find any help on "initial data values" in the scripting guide.
BR, Marianne
dt=current data table();
dt<Re: new column with initial data values
Ian_jmp:
Your idea works great! Thank you so much!
JMP_Learner
Re: new column with initial data valuesMaybe something like this?
NamesDefaultToHere(1);
// Make some tables, save and close them, but keep a list
n = 4;
fList = {};
for(t=1, t<=n, t++,
fName = "Table "||Char(t)||".jmp";
dt = NewTable(fName, NewColumn("Data", Formula(RandomInteger(10))));
dt << AddRows(20);
InsertInto(fList, fName);
Close(dt, Save("$DESKTOP/"||fName));
);
// Open the tables in the list and add the column
for(t=1, t<=NItems(fList), t++,
fName = fList[t];
dt = Open("$DESKTOP/"||fName);
colVals = {};
for(r=1, r<=NRow(dt), r++,
InsertInto(colVals, fName);
);
dt << NewColumn("File Name", Character, Values(colVals));
DeleteFile("$DESKTOP/"||fName);
);Re: new column with initial data valuesHi!
I have a similar but a little more complicated problem:
The initial value I try to set is a function of loop index.
Suppose I have 50 files to open. When open each file, I want to add a new column, and fill the new column with the file name of this file. The initial value is supposed to be a constant. But, when this function is used within a loop, the code seems stuck. It opens the first file, without filling the initial value, and stopped.
How should I make it work?
Thanks a lot.
new column with initial data valuesExcellent, just what I needed
new column with initial data valuesYou're close. This will work:
dt=current data table();
dt << new column("Selected", character, << set each value("YES"));
Re: new column with initial data valueshttps://community.jmp.com/t5/Discussions/Initialize-data-very-useful-but-fragile/m-p/780753