您好,我正在尝试检索并准备列名列表以保存在变量中以备后用。 问题是 << Get Column Names() 将所有内容作为字符串列表返回。 下面是我如何在每个项目字符串的开头添加一个“:”,以及它的潜在用途。 还有更多工作要做。
names default to here(1);
dt = current data table();
col_names = dt << Get Column Names( ); // retrieves all col names
col_list = {}; // list for holding col names
// loop formats names in way usable to be called on as cols, not strings
for( i = 1 , i <= N items( col_names ), i++,
list_item = ":" || list_item;
Insert Into( col_list, list_item );
);
dt << Ungroup Scripts( col_list ); // example usage另一个例子是将此列表用于以下内容:
拟合模型( Y( col_list ) ....
我得到什么:{“ColA”,“ColB”}
我想要什么:{ :ColA, :ColB }
我浏览并找到了多个与此相关的线程,但是我没有偶然发现使用列名作为函数的输入。有什么建议吗?