<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />I have a set of column names in a list called list_1, now I want to calculate the mean for each column, but the thing is I do not want to include all the rows in the column when calculating the mean, i have another pre-defined variable that selects specific rows. How do I calculate the mean of the column by selecting the specified rows instead of stepping down through all the rows?
for example i want the mean to be calculated based on rows 1,3,4,5,9 on a specific column
dt << current data table;
for (p=1,p<=nitems(list_1), p++,
col = list_1
;
mean = col mean(dt :col );
)
The col functions appear to ignore the excluded row state. This works however:
//for example i want the mean to be calculated based on rows 1,3,4,5,9 on a specific column
dt = New Table( "testmean", Add Rows( 10 ),
New Column( "C1", Numeric, Continuous, Format( "Best", 12 ),
Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ) ),
New Column( "C2", Numeric, Continuous, Format( "Best", 12 ),
Set Values( [5, 4, 3, 6, 7, 2, 3, 6, 5, 4] ) )
);
sel_rows = [1,3,4,5,9];
list_1 = {"C1", "C2"};
for (p=1, p <= nitems(list_1), p++,
one_col = list_1[p];
mean = mean(column(dt, one_col )[sel_rows]);
show(p, mean);
);