为每个子集表包含一个脚本大家好,
我正在创建很多子集表来清理我的数据,我想将相同的脚本应用于每个子集表。 我怎样才能做到这一点?
谢谢!
脚本回复:为每个子表包含一个脚本你好@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()”函数。