如果数据表中每个样本有多个条目,如何为列表中的每个样本运行脚本。我有一个数据表,其中多次测量相同的样本(参见下面的示例)。 样本由其标识符分隔。

我希望我的脚本能够对每个样本执行相同的计算集,以便我可以确定控制限并为 A、B、C 等制作控制图。 我不知道每个样本的标识符。 我已经有一个脚本可以进行计算并为我制作图表,它只是不能为每个标识符进行单独的计算。
我最初的做法是使用某种循环来做到这一点。 我有一个脚本,它返回列表中的每个唯一标识符,并为我提供唯一标识符的数量作为循环的设置。
Identifiers = Column( "Identifier") << GetAsMatrix();
Identifiers set = Associative Array( Identifiers);
Unique Identifiers = Identifiers set << Get Keys;
nUnique Identifiers = N Items (Unique Identifiers);
但我似乎无法让循环工作。 有一个更好的方法吗? 或者有人可以告诉我如何做循环吗?
我正在使用 JMP 10。
谢谢你!
质量和工艺工程回复:如果数据表中每个样本有多个条目,如何为列表中的每个样本运行脚本。就像魅力一样,谢谢!
回复:如果数据表中每个样本有多个条目,如何为列表中的每个样本运行脚本。如果您不想修改脚本,您可以针对标识符每个级别的子集运行它,如下所示:
Names default to here(1);
//Open some sample data
dt = Open( "$Sample_data/big class.jmp" );
//Your code
Identifiers = Column( "age") << GetAsMatrix();
Identifiers set = Associative Array( Identifiers);
Unique Identifiers = Identifiers set << Get Keys;
nUnique Identifiers = N Items (Unique Identifiers);
//A window to hold a bunch of graphs
win = New Window("Graphs", graphbox = v list box());
//Run an analysis on a subset of the data table for each level of a variable
for( i=1, i<=nUnique Identifiers, i++,
//Make a subset of the table with only values for this level
dt << Select Where( :age == UniqueIdentifiers[i]);
dtSub = dt << Subset("Selected Rows");
//run your existing script on the subset
//For demonstration, taking a picture of the graph builder platform
// and getting the R2 value from a linear model and adding those to a window
pic = (gb = dtSub << Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y, Legend( 2 ) ) ),
Local Data Filter(
Close Outline( 1 ),
Add Filter(
columns( :age ),
Where( :age == Unique Identifiers[i] ),
Display( :age, N Items( 6 ) )
)
)
)) << Get Picture;
graphbox << Append( pic );
gb << Close Window;
fm = dtSub << Fit Model(
Y( :height ),
Effects( :weight ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run(
:height << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
Parameter Estimates( 1 ), Scaled Estimates( 0 ),
Plot Actual by Predicted( 1 ), Plot Residual by Predicted( 1 ),
Plot Studentized Residuals( 0 ), Plot Effect Leverage( 1 ),
Plot Residual by Normal Quantiles( 0 ), Box Cox Y Transformation( 0 )}
)
);
Wait( 0 );
dtSum = Report( fm )[Outline Box( "Response height" )][Outline Box( "Whole Model" )][
Outline Box( "Summary of Fit" )][Table Box( 1 )] << Make Into Data Table;
Report( fm ) << Close Window;
Rsq = dtSum:Column 2[1];
graphbox << Append( Text Box( "RSquared was " || char(Rsq) ) );
dtSum << Close Window;
//close the subset
dtSub << Close Window;
);回复:如果数据表中每个样本有多个条目,如何为列表中的每个样本运行脚本。我如何能够进行按标识符过滤的额外计算? 我想做一些数据操作,然后根据每个标识符的数据计算我自己的限制,然后将其添加到每个图表中,因此我认为任何类型的过滤器都需要在最终图表脚本之前出现。 我有一个可以做到这一点的脚本,如果需要我可以发布它,但它很长。 我实际上只是在寻找一种方法来制作我已经为每个标识符而不是数据表中的所有行运行的脚本
回复:如果数据表中每个样本有多个条目,如何为列表中的每个样本运行脚本。我想知道使用内置控制图平台来计算限制和绘图度量是否有效,特别是如果您将标识符分配给“按分析”角色。
只是不希望您花费大量时间编写脚本,如果它重复了已经可用的功能。
回复:如果数据表中每个样本有多个条目,如何为列表中的每个样本运行脚本。有很多方法可以做到这一点,但其中一种方法就是向现有平台添加本地数据过滤器。这是使用图形生成器的示例:
Names default to here(1);
//Open some sample data
dt = Open( "$Sample_data/big class.jmp" );
//Your code
Identifiers = Column( "age") << GetAsMatrix();
Identifiers set = Associative Array( Identifiers);
Unique Identifiers = Identifiers set << Get Keys;
nUnique Identifiers = N Items (Unique Identifiers);
//A window to hold a bunch of graphs
win = New Window("Graphs", graphbox = v list box());
//Open a graph that is filtered to only show each unique identifier
//to keep things organized add it to a single window.
for( i=1, i<=nUnique Identifiers, i++,
win << Append(<BR /> //To get this script I opened graph builder and added a local data filter for one age<BR /> //and then copied/pasted it here and replaced the age with 4Unique Identifiers[i]
Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y, Legend( 2 ) ) ),
Local Data Filter(
Close Outline( 1 ),
Add Filter(
columns( :age ),
Where( :age == Unique Identifiers[i] ),
Display( :age, N Items( 6 ) )
)
)
)
)
);