将字符串列表转换为列名我正在尝试运行一个脚本,该脚本使用正则表达式来查找列名并将它们放在一个列表中然后堆叠。 我正在努力让实际的堆栈部分工作,我认为它与包含字符串而不是列名的列表有关。 有没有办法将列表字符串转换为列名?
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");
);Re: 将字符串列表转换为列名您的堆栈语法不正确:
- 有分号的地方应该有逗号
- 它不是源数据列而是堆叠数据列
edge stack = ref << stack(
columns( edgeCols),
Source Label Column("Label"),
Stacked Data Column("Data"),
Output Table("Stack")
);