將字串清單轉換為列名我正在嘗試運行一個腳本,該腳本使用正規表示式來查找列名稱並將它們放入列表中然後進行堆疊。 我正在努力讓實際的堆疊部分正常工作,我認為這與包含字串而不是列名稱的列表有關。 有沒有辦法將列表字串轉換為列名?
ref = open(dir||datafile);
allColNames = ref << getcolumnnames;
edgeCols = {};
Ncols = N items(allColNames);
for(i = 1, i <= Ncols, i++,
cname = Column(allColNames[i]) << get Name;
if(!Is Missing (regex(cname,"EDGE\d+") ),
insert into(edgeCols,cname);
);
);
edge stack = ref << stack(
columns(EdgeCols),
Source Label Column("Label");
Source Data Column("Data");
Output Table("Stack");
);回覆:將字串清單轉換為列名您的堆疊語法不正確:
- 應該有逗號的地方有分號
- 它不是來源資料列,而是堆疊資料列
edge stack = ref << stack(
columns( edgeCols),
Source Label Column("Label"),
Stacked Data Column("Data"),
Output Table("Stack")
);