MWE:
library(data.table) # version 1.9.6
DT = fread("https://raw.githubusercontent.com/Rdatatable/data.table/master/vignettes/melt_default.csv")
colA = paste("dob_child", 1:3, sep="")
colB = paste("gender_child", 1:3, sep="")
DT.m2 = melt(DT, measure = list(colA, colB), value.name = c("dob", "gender"))
代码取自data table vignette部分“3.增强(新)功能”。
运行代码会出错:
> DT.m2 = melt(DT, measure = list(colA, colB), value.name = c("dob", "gender"))
Error in melt.data.table(DT, measure = list(colA, colB), value.name = c("dob", :
Column 'ˆ ' not found in 'data'