同じ部品番号の測定値が複数あります。 1 つの列の最後のエントリを取得するにはどうすればよいでしょうか。

これはうまくいくかもしれない:
// make a column to hold results, it will be last column
dt << newcolumn("answer");
for(irow=1,irow<=nrows(dt),irow+=1,
// assumes columns 1 and 2 and last are NOT data...
// grab one row at a time...
vec = dt[irow, 3::(ncols(dt)-1)];
// get indexes (loc) of non-missing values...pick the right-most (max)
nonmissindex = max(loc(vec));
// handle possible edge case (no data)
value = if(ismissing(nonmissindex),.,vec[nonmissindex]);
// fill in the answers
dt:answer[irow] = value;
);
これを列式に変換する場合は、テーブルの更新のためにソース列を明示的にリストし、dt を必要としないようにする必要があります。
dt << New Column( "answer",
formula(
vec = run_1 || run_2 || run_3 || run_4;
nonmissindex = Max( Loc( vec ) );
If( Is Missing( nonmissindex ),
. // missing if all missing
, //
vec[nonmissindex]
);
)
);
数式なので、データが変更されると回答の列が更新されます。
私が考え出した式は次のとおりです
dt = Current Data Table();
x = Row();
col = Length( Loc( dt[x, Index( 3, 6 )] ) ) + 2;
dt[x, col];