您好,我正在嘗試檢索並準備列名列表以保存在變量中以備後用。 問題是 << 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 }
我瀏覽並找到了多個與此相關的線程,但是我沒有偶然發現使用列名作為函數的輸入。有什麼建議嗎?