你好,
尽管查看了许多讨论/脚本索引 ..,但我无法得到答案,如何编写 JSL 脚本,它将接管新的列命令,从而能够输入序列数据,每个值重复 N 次。 我知道如何手动完成 - 感谢 Mark B 的回复......在其中一个讨论中,但我很难编写脚本
例如
N_DOE= 10
N_XRF =4
=> {1,1,1,1,2,2,2,2,3,3,3,3, ...10,10,10,10}
//How may I get a column with repeating values
dt=current data table();
N_DOE=10;
N_XRF=4;
seq = sequence(1,N_DOE,1,N_XRF);
dt << new column("Run", "numeric", "ordinal");
//dt:run << set each value(seq,); // this works, but it is just"1" for all rows
dt:run << set each value(i=1,i<N_DOE></N_DOE>@PS_Ato , 吉姆, @txnelson已经提供了解决方案。
JMP函数,顺序()和数数()在处理数据表时是非常酷的函数,因为这两个函数都依赖于排()当前数据表。
有时您可能只希望矩阵中的序列。一种方法是矩阵函数直接产品(amat, bmat) .下面的脚本与您的原始脚本相似;它创建序号一个重复值的向量,然后将它们分配给新列。
这是作为 FYI 提供的。如果您没有使用过矩阵或没有学习过线性代数,这可能不会是您想到的第一个函数。
Names Default to Here(1);
N_DOE=10;
N_XRF=4;
New Table("Dummy", add rows(N_DOE * N_XRF));
dt=current data table();
seq = Transpose(Direct Product(Index(1,N_DOE),J(1,N_XRF,1)));
dt << new column("Run", "numeric", "ordinal", values(seq));
/* Log output
seq = Transpose(Direct Product(Index(1,N_DOE),J(1,N_XRF,1)));
[1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]
*/
Sequence() 函数实际上只在公式中起作用。 在脚本索引中查看它
帮助==>脚本索引.......序列
这是一个工作示例
names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");
N_DOE=10;
N_XRF=4;
dt << new column("Run", "numeric", "ordinal");
// Create the JSL required to set the format and then
// execute it
Eval( Parse(
"dt:run << set formula( sequence(1, " || char(N_DOE) ||
", ince = 1, n = " || char(N_XRF) || "));"
)
);