Hi,
I try to count and get specific column names from these data examples (my real data contained 180 columns and 20000 rows)
I want to select the column that cut-off > 1000
No. | A*1:01 | A*2:01 | B*9:02 | C*10:01 | DR*56:01 | DP*07_G | Get name |
1 | 10.67 | 0 | 9520.23 | 15000.1 | 90.56 | 40.89 | B*9:02, C*10:01 |
2 | 0 | 0 | 0 | 0 | 0 | 9.56 | |
3 | 9040.3 | 345.3 | 345.9 | 999.9 | 345 | 10.5 | A*1:01 |
4 | 34.4 | 4566 | 45 | 7 | 0 | 0 | A*2:01 |
5 | 9190.2 | 13567 | 3456 | 6789 | 9088 | 0 | A*1:01,A*2:01,B*9:02,C*10:01,DR*56:01 |
6 | 0 | 0 | 0 | 0 | 0 | 0 | |
... | | | | | | | |
I try the previous script like this
Names Default To Here( 1 );
// Create a sample data table
dt = New Table( "Example",
Add Rows( 2 ),
New Column( "A*1:01", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 50000] ) ),
New Column( "A*2:01", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 50000] ) ),
New Column( "B*9:02", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 50000] ) ),
New Column( "C*10:01", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 50000] ) ),
New Column( "DR*56:01", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 50000] ) ),
//get wanted columns. Assumes that IMC columns start from column 1 and all IMC columns are one after another
colNames = dt << Get Column Names("String");
For(i = N Items(colNames), i > 3000 , i--,
);
//new column with IMC with value 1
dt << New Column( "Ag", Character,
<< Set Each Value(
rowValues = dt[Row(), 0][1::N Items(colNames)]; //get values of row as matrix
colIndex = Contains(rowValues, 1); //get index of
If(colIndex > 0, //handle
colNames[colIndex], //get column name with the index
""; //when no 1 found use ""
);
);
);
Could you please to correct my scripts, Thank you!
In addition, can I use matrix because of I need to generate the "new column" of 180 column.
Best,