我第一次尝试使用应用程序构建器开发 JMP 插件,但是在编写 JSL 脚本时遇到了困难,如下所述:
背景:
该界面建立在对话框选项卡下。
有三个面板框,标题分别为Columns、Roles和Action,变量名分别为ColumnsPanel、RolesPanel和ActionPanel。
在“列”面板下,我添加了一个列列表框(全部),其变量名为 ColList,它将拉入打开的数据表中的所有列。
在角色面板下,我添加了三个 Col 列表框和三个按钮框:
第一、第二和第三个 Col List Box 的变量名分别为 ResponseColList、FactorColList 和 BlockColList。
第一、第二和第三个按钮框的变量名分别为 ResponseButton、FactorButton 和 BlockButton。
第一、第二和第三个按钮框的标题分别为“响应”、“因素”和“块”。
在Action面板下,我添加了三个按钮框,标题分别为OK、Remove和Cancel,变量名分别为OKButton、RemoveButton和CancelButton。
当我单击“响应”按钮时,它会从 ColList 中添加属性“A”、“B”、“C”、“D”和“E”的列。
类似地,当我单击“因素和阻止”按钮时,它会从 ColList 中添加“站点”和“人员”列。

脚本:
//Part I
//Places selected columns into Role panel
On Response = Function({},
ResponseColList << Append( AllColList << Get Selected)
);
//Places selected columns into Factor panel
On Factor = Function({},
FactorColList << Append( AllColList << Get Selected)
);
//Places selected columns into Block panel
On Block = Function({},
BlockColList << Append( AllColList << Get Selected)
);
// Program the OK Button
On OK = Function({},
Response = ResponseColList << Get Items;
Factor = FactorColList << Get Items;
Block = BlockColList << Get Items;
// Get the current data table
dt = Current Data Table();
// Perform principal component analysis
pca = dt << Principal Components(
Y( Eval List( Response ) ),
Estimation Method( "NIPALS" ),
Standardize( "Standardized" )
);
pca << Save Principal Component Values( 3 );
pca << Close Window();
// Create a subset and delete columns "Prin1", "Prin2" and ""Prin3" in "dt"
dt << Subset(
Output Table("MET"),
All rows,
columns(Eval List(Block), Eval List(Factor), :Prin1, :Prin2, :Prin3)
);
dt << Delete Columns( "Prin1" ) << Delete Columns( "Prin2" ) << Delete Columns( "Prin3" );
// Standardize column attributes and create a data table "MET"
Current Data Table(Data Table("MET"));
For Each({col, index}, {:Prin1, :Prin2, :Prin3},
col << Format("Fixed Dec", 12, 2)
);
MET = Data Table( "MET" );
//Part II
//Get the levels in the Factor column
factorLevels = Associative Array(MET, Column(Eval List(Factor))) << Get Keys;
level1 = factorlevels[1];
level2 = factorlevels[2];
// Create two subsets named "Group1" and "Group2"
MET << Select Where( Column(Eval List(Factor)) == level1 ) << Subset( Output Table( "Group1" ), Selected Rows( 1 ), Selected columns only( 0 ) );
MET << Select Where( Column(Eval List(Factor)) == level2 ) << Subset( Output Table( "Group2" ), Selected Rows( 1 ), Selected columns only( 0 ) );
Group1 = Data Table( "Group1" );
Group2 = Data Table( "Group2" );
// Access the Site levels in "Group1" and "Group2"
Site_level1 = Column( Group1, "Site" ) << Get Values;
Site_level2 = Column( Group2 "Site" ) << Get Values;
);我可以成功运行第一部分的脚本,但在第二部分中不断出现错误,因此非常感谢一些帮助调试代码。
这里的另一个目标是处理具有不同属性名称的数据集(例如,属性“F”,“G”等),我想确保脚本动态使用选定的列名而不是硬编码特定的名称。
谢谢你!
关联数组——以数据表作为第一个参数?
Names Default to Here(1);
MET = Open( "$SAMPLE_DATA/Big Class.jmp" );
Factor={"height", "weight"};
Associative Array(MET, Column(Eval List(Factor)))