Only manipulating column data onceHello!
I have a problem where I am multiplying a column of data (a bunch of Max Currents) by 100 to get Max Current Densities, and so when I run the script it does it fine:
column(13) << set values( (Column(13) << get as matrix) *100);
column(13) << set name("Max Jc (mA/um^2)");
But if I run the script multiple times it keeps multiplying the data by a hundred and I have to close the datatable and reopen it.
Is there a way to get it to only update once?
Thanks,
Tyler
Re: Only manipulating column data onceBased on @pmroz's input , you would want to change your code as follows :
//define columns to search for
colSearch1 = "Corrected Area";
colSearch2 = "Max Ic";
// Get Column Names from the data table
ColNames = dt << Get Column Names("string");
//search for desired columns
colNum1 = Contains(ColNames,colSearch1);
colNum2 = Contains(ColNames,colSearch2); Now you have reference for colNum1 and colNum2 as you need . Alternatively like @pmroz explained :
Col1 = column(dt,"Corrected Area") ;
Col2 = column(dt,"Max Ic") ;
Re: Only manipulating column data onceYou only need to get the column names once. That loads the column names into a list.
But you can also refer to columns directly using their names:
column(dt, "Max Ic (mA)") is an acceptable construct.
Re: Only manipulating column data onceSo I have to read in two columns that I eventually go on to use for a
simple bivariate analysis: Right now it doesn't work! Thanks again for all
the help and guidance!
//define columns to search for
colSearch1 = "Corrected Area";
colSearch2 = "Max Ic";
//get columns of interest
Col1 = dt << *Get Column Names(*"Corrected Area"*)*;
Col2 = dt << *Get Column Names(*"Max Ic"*)*;
//search for desired columns
colNum1 = Contains*(*Col1,colSearch1*)*;
colNum2 = Contains*(*Col2,colSearch2*)*;
//column(13) << set values( (Column( 13 ) << get as matrix) *100);
//column(13) << set name("Max Jc (mA/um^2)");
Column1 = Column*(*dt,colNum1*)* << *set values(* *(* Column1 << *get as
matrix)* **100)*;
Column1 << *set name(*"Max Jc (mA/um^2)"*)*;
Column2 = Column*(*dt,colNum2*)*;
Close*(*dt,Save*(filepath));*
//Call CreateBivariate to do a bivariate (two variable) analysis\
status = List*(0*,*0)*;
New Window*(*"Custom Analysis",
H List Box*(*
V List Box*(*
Panel Box*(*"Controls",
Text Box*(*"Choose Analysis"*)*,
choice = Check Box*({*"Distribution","Fit Line"*}*,
current = choice << *Get(1)*;
//xParam = Column(9);
//yParam = Column(13);
xParam = Column1;
yParam = Column2;
If*(* And*(* current, Not*(*status*[**1]* *)* *)*,
dt << *Append(*
dt = V List Box*(*
bivDistribution = Distribution*(*
Y*(* Eval*(*yParam*)* *)*,
X*(* Eval*(*xParam*)* *)*,
*)*;
*)*
Re: Only manipulating column data once@tylerram93 ,
This should do it .
// Open Sample Data Table
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Define Column To Search For
ColToSearch = "age";
// Get Column Names
ColNames = dt << Get Column Names("String");
// Search if the desired column names exists
ColNum = Contains(ColNames,ColToSearch);
// Get Reference to desired Column
Col = Column(dt,ColNum);
// Alternatively
Col(ColNum) // Also refers to your desired column Re: Only manipulating column data onceThat worked perfectly! Thanks!
Follow-up question:
Is there a way to select columns based off of their name? So instead of using Column(13) it can search for the column with "Max Ic (mA)"
Thanks,
Tyler
Re: Only manipulating column data onceHello @tylerram93 :
Simple way to fix this is - you make sure that the table is closed at the end of the script . As long as your raw data is consistent , irrespective of how many times you run the script and save and close it at the end as shown below - the multiplication should only happen once .
By not closing the table , you are modifying the table repeatedly I would think.
In case - I have misunderstood your question - please paste a test data set and test script .
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
column(4) << set values( (Column(4) << get as matrix) *100);
column(4) << set name("Max Jc (mA/um^2)");
Close(dt,Save(FilePath));
Best
uday