複数のサブセット化されたデータテーブルから選択した行を1つの新しいデータテーブルに連結しますHi,<BR /><BR />I have a data set(as example, Big Class) that contains all the data. I subset the data by age and select first row of each <BR />subsetted data table. Then, I subset it again so that I can do concatenation of the selected row data into new table. <BR /><BR />I notice that there is additional data (unwanted data ) concatenated in the new table (highlighted in red rectangular). <BR />I am not sure what is the problem of my script. <BR />I attach my script in below.<BR /><SPAN>I really appreciate if anyone could help me to fix this issue.</SPAN><BR />
// Open Big Class data table
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
//Subset the data table by age
listDT = dt << Subset(
By( :age ),
All rows,
Selected columns only( 0 ),
columns( :name, :sex, :height, :weight )
);
//Select first row of each subset data table
For( i = 1, i <= N Items( listDT ), i++,
listDT[i] << Select Rows( {1} );
listDT[i] << Subset("");
Close(listDT[i],"No Save");
Close(dt,"No Save");
);
// Create Tables list
Tables = {};
For( i = 1, i <= N Table(), i++,
Insert Into( Tables, Data Table( i ) << get name );
);
//Create new table
New Table("FirstRowData");
// Run the concatenations
For( i = 1, i <= N Items( Tables ), i++,
Data Table( "FirstRowData" ) << Concatenate(
Data Table( Tables[i] ),
append to first table(1)
);
Close( Data Table( Tables[i] ), No Save );
);
スクリプティングRe:複数のサブセット化されたデータテーブルから選択した行を1つの新しいデータテーブルに連結しますこんにちは、
ここでの問題は、サブセットごとに作成されたテーブル変数にあるようです。次に、同じ名前( "age")のテーブル変数が、連結ごとに列として追加されていました。以下のスクリプトを参照して、テーブル変数を削除するためにForループが追加されていることに注目してください。これで問題は解決しますか?
// Open Big Class data table
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
//Subset the data table by age
listDT = dt << Subset(
By( :age ),
All rows,
Selected columns only( 0 ),
columns( :name, :sex, :height, :weight )
);
//Select first row of each subset data table
For( i = 1, i <= N Items( listDT ), i++,
listDT[i] << Select Rows( {1} );
listDT[i] << Subset("");
Close(listDT[i],"No Save");
Close(dt,"No Save");
);
// Create Tables list
Tables = {};
For( i = 1, i <= N Table(), i++,
Insert Into( Tables, Data Table( i ) << get name );
);
//Delete table variables
For( i = 1, i <= N Table(), i++,
Data Table(Tables[i]) << Delete Table Variable("age");
);
//Create new table
New Table("FirstRowData");
// Run the concatenations
For( i = 1, i <= N Items( Tables ), i++,
Data Table( "FirstRowData" ) << Concatenate(
Data Table( Tables[i] ),
append to first table(1)
);
Close( Data Table( Tables[i] ), No Save );
);Re:複数のサブセット化されたデータテーブルから選択した行を1つの新しいデータテーブルに連結しますありがとうございました!
それは完璧に動作します