為每個子集表包含一個腳本大家好,
我正在創建很多子集表來清理我的數據,我想將相同的腳本應用於每個子集表。 我怎樣才能做到這一點?
謝謝!
腳本回复:為每個子表包含一個腳本你好@LGaspard ,
您想要將表腳本從源集複製到子集嗎?如果是這樣,您可以通過打開示例數據集(例如 Big Class)並創建一個隨機子集來驗證是否發生這種情況。所有表子集都被複製到新創建的子集中。
如果您希望腳本窗口中的腳本應用於子集,請確保在創建時為您的子集命名。 這是一個例子。
Names default to here(1);
bigclass = open( "$SAMPLE_DATA/Big Class.jmp" );
// Subset data table
bigclass << Row Selection(
Select where( :Height >= 65 ) );
dt << Subset( (Selected Rows), Output Table Name( "Tall_children" ) );
tallchildren = data datable( "Tall_children" );
/* Call on tallchildren to work with the data table (subset) that you just created */
回复:為每個子表包含一個腳本是的,所以我有一個主數據表,我從中創建了大約 10 個不同的子表。 我想將相同的腳本添加到每個子集表。 任何想法?
另外,我可以將所有子集表一一重命名嗎?
謝謝!
回复:為每個子表包含一個腳本這是一個使用 Expr() 來保存要多次使用的腳本的簡單示例
names default to here( 1 );
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
summarize( ageList = by( :Age ) );
// Here is the script that will be applied to each data table
theScript = Expr(
dt << new column( "Ratio", formula( :height / :weight ) );
dt << set name( "The Table Name is Age=" || ageList[i])
);
// Create a data table for each level of Age in the data table.
// The list called dtList will contain a refereence to each individual
// table created
dtList = Data Table( "Big Class" ) << Subset(
Output Table( "Untitled 2.jmp" ),
By( :age ),
All rows,
Selected columns only( 0 ),
columns( :name, :sex, :height, :weight )
);
show( dtList );
For( i = 1, i <= n items( dtList ), i++,
dt = dtList[i];
// Run the script
theScript;
);
您可能還想查看“Include()”函數。