执行以下代码时
data <- data.frame( A = c("foo", "foo", "bar", "bar"),
B = c("foo","bar", "foo", "bar"),
C = c("bla", "foo", "bla", "bar"),
D = c(1, 2, 3, 4 ),
E = c(5, 6, 7, 8 ))
ds <- split(data, list(data$A, data$B, data$C), drop=TRUE)
write.table(ds[1], file="foo.csv", append=FALSE, row.names=FALSE)
foo.csv 看起来像这样:
"bar.bar.bar.A","bar.bar.bar.B","bar.bar.bar.C","bar.bar.bar.D","bar.bar.bar.E"
"bar","bar","bar",4,8
即,列名包含用于拆分的列的内容。如何以通用方式将名称更改回原始名称?(我不想分配像“A”、“B”、....这样的列名)