用于更改标题中包含字符串的所有列的数据类型的脚本?我正在尝试编写一个脚本,将标题中带有“平均值”一词的所有列更改为数字数据类型和连续建模类型。
我收到有关最后一行“cols << data type("numeric")”的错误“Send Expects Scriptible Object”。我该如何修复我的代码?或者有没有更简单的方法来完成相同的任务?
cols = dt << get column names( string );
For( i = N Items( cols ), i>=1, i--,
If( Contains( cols[i], "Mean" ),
cols << data type("numeric");
)
);我正在使用 JMP Pro 16。谢谢!
自动化和脚本视窗回复:用于更改标题中包含字符串的所有列的数据类型的脚本?你向错误的变量发送了消息。例如
cols = dt << get column names(string);
For(i = N Items(cols), i >= 1, i--,
If(Contains(cols[i], "Mean"),
Column(dt, cols[i] << data type("numeric")
)
);
应该可以。我还会稍微重写一下脚本(使用 For Each 和 << Set Data Type),因为我认为它们更容易阅读
cols = dt << get column names("String");
For Each({col}, cols,
If(Contains(col, "Mean"),
Column(dt, col) << Set Data Type("Numeric");
);
);回复:用于更改标题中包含字符串的所有列的数据类型的脚本?谢谢!第二个脚本运行良好。