I have a table with variable numeric, continuous column names. I need to get the mean of each column, grouped by a different column. The script below shows what I'm trying to do and it makes a generic table that works for this purpose. I'm getting hung up on the "Mean(ColNames)" line because it can't seem to process that.
If I replace "Mean(ColNames)" with "Mean(:Col2, :Col3)" or "Mean(:Name("Col2"), :Name("Col3"))" then it works but obviously doesn't meet my need of being able to use variable columns. Am I close or way off?
// Make a table to work with
nr = 20;
nc = 3;
dt = NewTable("Random_Table");
For(c=1, c<=nc, c++,
dt << NewColumn("Col"||Char(c), Numeric, Continuous, Formula(RandomInteger(1, 10)));
);
dt << AddRows(nr);
Column(1) << Data Type(Character);
//Get column names for the numeric continuous columns
ColNames = dt << Get Column Names(Numeric, "Continuous");
dt << Summary(
Group(:Col1),
Mean(ColNames),
statistics column name format( "column" )
);