データが空のセルを選択する以下のようなテーブルがあります。
| オペレーター |
Mタイプ |
説明 |
説明2 |
M1 |
M2 |
M3 |
M4 |
M5 |
M6 |
| 415 |
Nxyz |
暑い |
ホットクリーン1 |
415 |
415 |
415 |
415 |
415 |
415 |
| 615 |
Nxyz |
B 寒い |
コールドクリーン1 |
615 |
615 |
615 |
|
615 |
615 |
| 815 |
Nxyz |
暑い |
ホットクリーン2 |
815 |
815 |
815 |
815 |
815 |
815 |
| 1015 |
Nxyz |
B 寒い |
コールドクリーン2 |
1015 |
|
1015 |
1015 |
1015 |
1015 |
| 1215 |
Nxyz |
暑い |
ホットクリーン1 |
1215 |
1215 |
1215 |
1215 |
1215 |
1215 |
| 1415 |
Nxyz |
B 寒い |
コールドクリーン1 |
1415 |
1415 |
1415 |
1415 |
1415 |
|
| 1615年 |
Nxyz |
暑い |
ホットクリーン2 |
1615年 |
1615年 |
1615年 |
1615年 |
1615年 |
1615年 |
| 1815年 |
Nxyz |
B 寒い |
コールドクリーン2 |
1815年 |
1815年 |
1815年 |
|
|
1815年 |
空の行のみを選択したいと考えています。 列 M1 ~ M6 はデータを取得するたびに変化する可能性があるため、JSL スクリプトでは列名を使用できません。 以下の FOR ループを使用して空のデータの行を選択しようとしていますが、これでは最後のセルが空の行のみが選択されます。
dt = Current Data Table();
nc = dt << get column names( Numeric );
For( i = 1, i <= N Items( nc ), i++,
dt <<SELECT where=""></SELECT>
最終的には次のような出力テーブルを取得したいと考えています
| オペレーター |
Mタイプ |
説明 |
説明2 |
機械 |
| 615 |
Nxyz |
B コールド |
コールドクリーン1 |
M4 |
| 1015 |
Nxyz |
B 寒い |
コールドクリーン2 |
M2 |
| 1415 |
Nxyz |
B 寒い |
コールドクリーン1 |
M6 |
| 1815年 |
Nxyz |
B 寒い |
コールドクリーン2 |
M4 |
| 1815年 |
Nxyz |
B 寒い |
コールドクリーン2 |
M5 |
これの大きなコツは、列名 (M1、M2 など) が変更されるため、その列名をコーディングせずにこれを行うことです。
何か案は
自動化とスクリプト作成Re: データが空のセルを選択する<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />皆さんありがとうございます....Loc Nonmissing以外はすべて機能しました....私は現在JMP9しか持っていません(アップグレードするのが面倒です)、その機能はJMP9では機能しません....まだですJSL初心者....またよろしくお願いします
Re: データが空のセルを選択するMS はさらにスムーズです - 0 行のコードでそれを実行できるのを見てみましょう!ははは、JSL で同じことを行う方法がいくつかあることを示しただけです。
Re: データが空のセルを選択するあなたのメッセージを正しく読んでいるなら、実際には 2 つの質問があると思います。
- 特定の列セットですべてが欠落している行を検索する方法。
- コードをそれらの列の名前と列の数に依存させないようにする方法。
当然のことながら、1 を実行するにはさまざまな方法があります。 ピームローズ、 MSそしてクレイジ@JMPそこでいくつかのオプションを提供しました。
もう一つ投入します。 を使用できます欠落データのパターンそれらを見つけるためのユーティリティ。
dt = Open( "$SAMPLE_DATA\Cities.jmp" );
//delete some columns from this table to make it fit your example
dt << delete columns( "PM10", "X", "Y" );
//change name of data table to ensure this modified version doesn't get saved
//over the sample data
dt << set name( "CitiesModified" );
//I want to use the columns starting at column 9,
//so I build a list of references to them
mycols = {};
For( i = 9, i <= N Cols( dt ), i++,
Insert Into( mycols, Column( dt, i ) )
);
mdp = Dt << Missing Data Pattern( columns( Eval( mycols ) ), Output Table( "Missing Data Pattern" ) );
//The patterns columns shows the pattern of missing values
//the Missing Data Pattern data table is sorted,
//so if there are rows with all missing data
//the last row of the Missing Data Pattern data table will be all 1s.
//The Repeat() function just builds a string of 1s for as many columns as I'm working with
If( Column( mdp, "Patterns" )[N Rows( mdp )] == Repeat( "1", N Items( mycols ) ),
//The Missing Data Pattern data table is linked to the source table so selecting a row
//in it, selects all the rows that it represents in the source table
mdp << Select Rows( N Rows( mdp ) );
//now I can delete the rows in the source table
dt << delete rows;
,
Show( "No all missing rows" )
);
このコードを任意の数の列で機能させる方法を示してみました。 この場合、Missing Data Pattern ユーティリティに渡す列のリストが必要だったので、列番号に基づいてリストを作成しました。
ここまで書いて、Missing Data Pattern Utility の使用方法を示したとしても、ここでの私のお気に入りの解決策は次のとおりだと思います。ピームローズを使用しますスタック列。 最終的にはデータを積み上げたいと考えているため、最初にこれを行うと、積み上げられた列で欠落している行を選択して削除することが簡単になります。
dt = Open( "$SAMPLE_DATA\Cities.jmp" );
//delete some columns from this table to make it fit your example
dt << delete columns( "PM10", "X", "Y" );
//change name of data table to ensure this modified version doesn't get saved
//over the sample data
dt << set name( "CitiesModified" );
//again I need a list of columns to use in the Stack()
mycols = {};
For( i = 9, i <= N Cols( dt ), i++,
Insert Into( mycols, Column( dt, i ) )
);
//stack those columns creating a new data table
stacked_dt = dt << Stack(
columns( Eval( mycols ) ),
Source Label Column( "Gas" ),
Stacked Data Column( "PPM" )
);
missing_rows = stacked_dt << get rows where( Is Missing( :PPM ) );
stacked_dt << delete rows( missing_rows );
Re: データが空のセルを選択する空のセルを含む行を選択するさらに別の方法:
dt << select where(!Contains(Loc Nonmissing(dt << get as matrix), Row()));
Re: データが空のセルを選択するとても滑らかです。式 (e) に挿入できるとは知りませんでした。私は思ったに挿入するリストが必要でした。
Re: データが空のセルを選択すると同じ答えピームローズ式操作を使用する:
dt = Current Data Table();
e = Expr( Or() ); // the OR of the ismissing(columns) will be built here
nc = dt << get column names( Numeric );
For( i = 1, i <= N Items( nc ), i++,
Insert Into( e, Eval Expr( Is Missing( Expr( nc ) ) ) )
);
dt << selectwhere( e );
式「e」は次のようになります
nameexpr(e)
/*:
Is Missing( :m1 ) | Is Missing( :m2 ) | Is Missing( :m3 ) | Is Missing( :m4 ) | Is Missing( :m5 ) | Is Missing( :m6 )
Head Arg 再帰式
内省

Re: データが空のセルを選択するSTACK コマンドを使用して、 M1 ~ Mn の値を含むデータをスタックできます。次に、空の行を選択して削除します。
または、次のコードを試してください。
dt = Current Data Table();
col_list = dt << get column names( Numeric, string );
where_clause = "";
For( i = 1, i <= N Items( nc ), i++,
one_col = col_list[i];
if (i == 1,
// then
where_clause =evalinsert("\[dt << select where(is missing(as column(dt, "^one_col^"))]\");
// else
,
where_clause = evalinsert("\[^where_clause^ | is missing(as column(dt, "^one_col^"))]\");
);
);
where_clause = where_clause || ")";
eval(parse(where_clause));