Ciao comunità JMP,
Ho un elenco di intestazioni di colonna (17 sonde di acquisizione) e, a seconda dei dati, un particolare set di dati può avere un numero qualsiasi di quelle 17 sonde di acquisizione.
Devo creare uno script in cui la funzione stack impilerà le colonne esistenti nel set di dati e ignorerà qualsiasi altra colonna mancante.
Ho estratto lo script sorgente per un particolare set di dati e ho provato a inserire un'istruzione if() con un ciclo per provare a ottenere questo risultato, ma continua a non funzionare perché alcune colonne non sono state trovate.
Ho incluso lo script che ho ora.
</CODE></PRE><PRE><CODE class=" language-jsl">dt = Current Data Table();
text_col_list =
{"SP1_A","SP12_B","SP35_A","SP37_A","SP5_A","SP7_A","SP2_A","SP39_A","SP38_A","SP41_A","SP40_A","SP42_A","SP3_A","SP4_A","SP6_A","SP10_A","SP11_A"};
jmp_col_list =
{"cSCR1","CP 34","CP 24 v.6.3","CP 34 v.1","CP 24 v.1","CP 44 v.1","CP 24","CP24 v.14
","CP24 v.13","CP24 v.16","CP24 v.15","CP24 v.17","CP 26","CP 44","CP 24 v.10","CP 32","CP 33"};
col_name_list = dt << get column names(string);
for (i = 1, i <= nitems(text_col_list), i++,
if (contains(col_name_list, text_col_list[i]),
column(dt, text_col_list[i]) << set name(jmp_col_list[i]);
);
);
dt = Current Data Table();
jmp_col_list =
{"cSCR1","CP 34","CP 24 v.6.3","CP 34 v.1","CP 24 v.1","CP 44 v.1","CP 24","CP24 v.14
","CP24 v.13","CP24 v.16","CP24 v.15","CP24 v.17","CP 26","CP 44","CP 24 v.10","CP 32","CP 33"};
col_name_list = dt << get column names(string);
for (i = 1, i <= nitems(jmp_col_list), i++,
if (contains(col_name_list, jmp_col_list[i]),
<< Stack(columns(jmp_col_list),
<<IGNORE errors=""></IGNORE>
Se la mia interpretazione dei vari elenchi nel tuo script è corretta e ciò che penso tu stia tentando di fare, credo che il seguente script farà ciò che desideri
Names Default To Here( 1 );
dt = Current Data Table();
// List of possible columns to be stacked
jmp_col_list = {"cSCR1", "CP 34", "CP 24 v.6.3", "CP 34 v.1", "CP 24 v.1", "CP 44 v.1",
"CP 24", "CP24 v.14", "CP24 v.13", "CP24 v.16", "CP24 v.15", "CP24 v.17", "CP 26",
"CP 44", "CP 24 v.10", "CP 32", "CP 33"};
// List name of the list of columns found in the current data table
found_List = {};
// Columns in the data table
col_name_list = dt << get column names( string );
// Loop through the columns in the data table, and if found in the
// jmp_col_list, then place them into the found_List
For( i = 1, i <= N Items( col_name_list ), i++,
If( Contains( jmp_col_list, col_name_list[i] ),
Insert Into( found_List, col_name_list[i] )
)
);
// Stack the columns found
dtStacked = dt << Stack(
columns( Eval( found_list ) ),
Source Label Column( "Capture Probes" ),
Stacked Data Column( "Intensity" ),
Name( "Non-stacked columns" )(Keep(
:Filename,
:Condition,
:Rep #,
:Name( "Time (s)" ),
:Name( "Date/Time" ),
:Cartridge #
))
);