我希望使某些函数更易于重复使用,例如,我正在创建一个包含数据集中特定列的汇总表。我想将列表作为参数传入,以便我拥有一个“GetSummary”函数,而不是“GetExperimentsSummary”和“GetCompoundsSummary”,但由于它们需要不同数量的列,我需要能够单独打包列表(最有可能在我的类定义中),然后将它们作为一个参数传递给函数。这在 jsl 中可行吗?语法是什么?下面是我的获取实验和获取化合物的示例,我在 JMP18 上。
//Get Experiments function
getexperimentssummary = function ({},
original_data << Summary(
Group(
:ExperimentID, :Read Date, :Experiment Type, :Plate Size, :Plate Type,
:Dispense Mode, :Probook Number, :Probook Page Number, :Experiment Notes
),
Freq( "None" ),
Weight( "None" ),
output table name("Experiment_summary")
);
experiment_summary = Data Table ("Experiment_summary");
experiment_id = "ExperimentID";
);
//Get Compounds Summary
getcompoundssummary = Function( {},
original_data << Summary(
Group(
:CompoundID, :Compound, :Compound Lot Number, :Compound Supplier, :Compound Catalog Number
),
Freq( "None" ),
Weight( "None" ),
output table name("Compound_summary")
);
compound_summary = Data Table ("Compound_summary");
Compound_ID = "CompoundID";
);
您正在寻找这样的东西吗?
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
get_summary = function({dt, collist}, {Default Local},
dt_summary = dt << Summary(
Group(Eval(collist)),
Freq("None"),
Weight("None"),
Link to original data table(0),
output table name((dt << get name) ||" Summary")
);
return(dt_summary);
);
dt_summary1 = get_summary(dt, {"sex"});
dt_summary2 = get_summary(dt, {"sex", "age"});