Devo scrivere uno script per trovare tutte le righe nella tabella con valore> 50 e restituire 10 righe subito dopo quelle righe. Qualcuno potrebbe aiutarmi con questo script, per favore? Grazie!
Senza alcuna conoscenza dei dati che hai qui c'è un'opzione con cui potresti iniziare (cerca valori superiori a 120 e non a 50)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
r = As List(dt << Get Rows Where(:weight > 120));
rs = {};
max_rows = N Rows(dt);
For Each({cur_r}, r,
Insert Into(rs, Index(cur_r + 1, Min(max_rows, cur_r + 10)));
);
show(r);
show(rs);
// r = {2, 4, 7, 18, 30, 37, 39, 40};
// rs = {[2 3 4 5 6 7 8 9 10 11], [4 5 6 7 8 9 10 11 12 13], [7 8 9 10 11 12 13 14 15 16], [18 19 20 21 22 23 24 25 26 27], [30 31 32 33 34 35 36 37 38 39], [37 38 39 40], [39 40], [40]};
</CODE></P></LINGO-BODY><LINGO-SUB id="lingo-sub-754828" slang="en-US" mode="CREATE">Ri: trova tutte le righe con valore>50 e le successive 10 righe</LINGO-SUB><LINGO-BODY id="lingo-body-754828" slang="en-US" mode="CREATE"><P>Ecco tre diverse opzioni, che potrebbero acquisire righe errate a causa di errori sfalsati</P>
<PRE><CODE class=" language-jsl">// Option1
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// https://leetcode.com/problems/merge-intervals/solutions/3161191/solution/
merge_intervals = function({intervals}, {Default Local},
// Assumes array is sorted by first index
stack = {};
For Each({interval}, intervals,
If(N Items(stack) == 0 | stack[N Items(stack)][2] < interval[1],
Insert Into(stack, Eval List({interval}));
,
stack[N Items(stack)][2] = max(stack[N Items(stack)][2], interval[2]);
);
);
return(stack);
);
r_start = (dt << Get Rows Where(:weight > 120)) + 1;
r_end = r_start + 10;
toohigh = Loc(r_start > N Rows(dt));
r_start[toohigh] = N Rows(dt);
toohigh = Loc(r_end > N Rows(dt));
r_end[toohigh] = N Rows(dt);
rs = As List(r_start || r_end);
res = merge_intervals(rs);
// Option2
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
r_start = dt << Get Rows Where(:weight > 120);
res2 = dt << get rows where(Any(Row() > r_start & Row() <= r_start + 10));
// Option3
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
r = As List(dt << Get Rows Where(:weight > 120));
rs = {};
max_rows = N Rows(dt);
For Each({cur_r}, r,
Insert Into(rs, As List(Index(Min(max_rows, cur_r + 1), Min(max_rows, cur_r + 10))));
);
Seleziona il messaggio << Seleziona righe() nella tabella dati.
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
r_start = dt << Get Rows Where(:weight > 120);
res2 = dt << get rows where(Any(Row() > r_start & Row() <= r_start + 10));
dt << Select Rows(res2);Per trasformare le righe selezionate in una nuova tabella dati è sufficiente utilizzare la piattaforma dei sottoinsiemi.
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
r_start = dt << Get Rows Where(:weight > 120);
res2 = dt << get rows where(Any(Row() > r_start & Row() <= r_start + 10));
dt << Select Rows(res2);
dtSub = dt << subset( selected rows(1), selected columns(0));Grazie mille! Come posso trasformare rs (tutte le righe selezionate) in una nuova tabella dati?