尋找缺少從 X 列開始直到 ncol()你好,
我有一張包含數千列的表。我想使用列矩陣來尋找一系列列是否缺失。
我先使用 Loc() 來決定第一個列號的起始。
allcol = dt << 取得列名(字串);
colname = column ("起始列") << getname;
列號 = (Loc(allcol,列名))[1];
然後我想查找從 colnumber 到 ncol() 的列是否缺失。類似下面的操作但失敗了。有人能告訴我該如何做對嗎?
dt << 選擇其中(ismissing(column()[colnumber :: ncol()]))
自動化和腳本回覆:尋找缺少從 X 列開始直到 ncol()以下是找出每個行列範圍內有缺失值的行的範例。
Names Default To Here( 1 );
dt =
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
// for example purposes set some random cells to missing values
For( i = 1, i <= Random Integer( 1, 100 ), i++,
random row = Random Integer( 1, 1455 );
random col = Random Integer( 5, 132 );
dt[random row, random col] = .;
);
starting colName = "NPN1";
allcol = dt << get column names( string );
starting col = Contains( allcol, starting colName );
rowsWithMissing = [];
For Each Row(
mat = dt[Row(), starting col :: N Col( dt )];
If( Length( Loc( mat, . ) ) > 0,
rowsWithMissing = rowsWithMissing || matrix(row());
);
);
show(rowsWithMissing);