Re: JSL Scripting Help Needed - Generalizing Split ColumnsI this part:
//Step 3: Split data (this part is not working)
rd_split = rd_summary << Split(
Split By( :Treatment ),
Split( SummaryMetricNames),
Group( :Participant Name ),
Remaining Columns( Drop All ),
Sort by Column Property
)
The issue is with the SummaryMetricNames. This variable isn't evaluated. ... and you need to get each of the column name, comma delimited, into the split() which is inside a split().
dt=current data table();
dt<<GET column="" names=""></GET>
I could have itereated through the list of column names and inserted each one separately into the expression splitter, but this line does the same thing in one step
insert into (splitter, substitute ( cols , expr(split({})), expr( split()))); JSL Scripting Help Needed - Generalizing Split ColumnsI am trying to generalize splitting columns in a data table that can have any number of columns to split. I am identifying them by looking for the word "Parameter." I am doing something wrong in Step 3, I believe, when referecing SummaryMetricNames.
Thank you in advance!
//Step 1: Get the means of columns in ColList (select metric columns from a table I got using Get Column Names)
rd_summary = rd << Summary(
Group( :Participant Name, :Treatment ),
Mean( ColList),
Freq( "None" ),
Weight( "None" ),
statistics column name format( "column" )
);
//Step 2: Get list with just means columns from the table
SummaryMetricNames = rd_summary << Get Column Names;
For( i = N Items ( SummaryMetricNames ), i>=1, i--,
If ( Contains( SummaryMetricNames[i],"Parameter" )==0,
SummaryMetricNames = Remove( SummaryMetricNames, i, 1 )
)
);
//Step 3: Split data (this part is not working)
rd_split = rd_summary << Split(
Split By( :Treatment ),
Split( SummaryMetricNames),
Group( :Participant Name ),
Remaining Columns( Drop All ),
Sort by Column Property
);