大家好,
例如,我注意到分发平台似乎不像图形生成器那样接受列引用。
我有代码使用 Column(dtname, number) 格式引用数据表中的不同列。 例如,这是我用 GB 执行的一段代码,它工作得很好:
Graph Builder(
Size( 500, 350 ),
Show Control Panel( 0 ),
Variables(
X( Column( dt_results, NNxcol ) ),
Y( Column( dt_results, NNYCol + N Items( NNXList ) ) ),
Y( Column( dt_results, NNYCol + 1 + N Items( NNXlist ) ), Position( 1 ) ),
Y( Column( dt_results, NNYCol + 2 + N Items( NNXList ) ) )
),
Elements(
Position( 1, 1 ),
Points( X, Y( 1 ), Y( 2 ), Legend( 8 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Legend( 9 ) )
),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 10 ) ), Smoother( X, Y, Legend( 11 ) ) ),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( NNYList[NNYCol] || " Stats vs. " || NNXList[NNxcol] )}
),
Dispatch( {}, "Y title", TextEditBox, {Set Text( NNYList[NNYCol] || " Train & Valid" )} )
)
)
但是,当我尝试在分发平台中执行类似的操作时,没有任何反应,我认为这是因为 Continuous Distribution() 调用似乎不喜欢以这种方式引用列。 它似乎喜欢将列引用为 Column(列名称)。
Distribution(
Continuous Distribution( Column( dt_results, NNYCol + NNcolshift ), Quantiles( 0 ) ),
Continuous Distribution( Column( dt_results, NNYCol + 1 + NNcolshift ), Quantiles( 0 ) ),
Continuous Distribution( Column( dt_results, NNYCol + 2 + NNcolshift ), Quantiles( 0 ) )
)
我想在调用平台时使用变量,因为它在代码中更灵活,而不是在列名称本身中进行硬编码。 知道为什么分发平台的行为不同或者如何正确引用该列以便获得预期的输出吗?
任何想法/评论表示赞赏。
谢谢!,
DS
您只需向数据表发送消息并删除 Column() 函数中的表引用即可。至于为什么它不喜欢与 Graph Builder 一起使用的脚本的语法,我不知道。
dt_results << Distribution(
Continuous Distribution( Column( NNYCol + NNcolshift ), Quantiles( 0 ) ),
Continuous Distribution( Column( NNYCol + 1 + NNcolshift ), Quantiles( 0 ) ),
Continuous Distribution( Column( NNYCol + 2 + NNcolshift ), Quantiles( 0 ) )
)
您可以使用这样有趣且令人困惑的语法
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
col1 = "height";
col2 = "weight";
dist = dt << Distribution(
Continuous Distribution(Column(Column(dt, col1)), Quantiles(0)),
Continuous Distribution(Column(Column(dt, col2)), Quantiles(0))
);
或这个
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
col1 = "height";
col2 = "weight";
Eval(EvalExpr(
dist = dt << Distribution(
Continuous Distribution(Column(Eval(col1)), Quantiles(0)),
Continuous Distribution(Column(Eval(col2)), Quantiles(0))
);
));
编辑: Eval(EvalExpr()) 在上面的脚本中是不必要的。 在测试不同的选项时(正在使用 Name Expr(AsColumn())),我不小心将其留在那里。
或者只是其中之一:
dt = Open("$SAMPLE_DATA/Big Class.jmp");
col1 = "height";
col2 = "weight";
Distribution(Continuous Distribution(Column(Eval(col1))));
colList={col1,col2};
Distribution(column(EvalList(colList)));
更多详细信息可以在这里找到:
https://www.pega-analytics.co.uk/blog/handling-lists-of-columns/ (谢谢@雷塞尔
和这里:
https://community.jmp.com/t5/Discussions/Updating-column-list-box-using-list-stored-in-variable-not/mp/687314/highlight/true#M87301
造成混乱的原因是(众所周知)柱子用作一个名称命名参数在连续分布。许多 Jmp 用户会认为这是柱子()功能并相应地使用它。
Col 列表框中的 Data Table() 相同:使用存储在变量中的列表更新列列表框未按预期工作。 这是它本来的样子吗?
大家好,
感谢您对此的一些快速反馈和帮助。 我最终选择了混合@mmarchandTSI和@jthi的第二个建议。 不幸的是,来自的建议@mmarchandTSI最终并没有自行工作,平台仍然不喜欢 Column() 引用中的列号变量。 但是,如果我随后对 Column() 引用中的数字变量执行 Eval(),那么效果就很好。 因此,使用 Column(Eval()) 作为@jthi和@hogi做到了,最终按预期工作。
感谢您的宝贵建议!,
DS