df1<-data.frame(id=c("a","b","c","d"),
var1=c(2,4,4,5),
var2=c(5,6,2,6),
var3=c(5,3,2,1))
msr<-c("var1", "var2","var3")
melt(df1,
id.vars = -c(msr), #problem here
measure.vars = c(msr))
I have a dataframe similiar to this, except with a large number of id.vars. I would like to include all of them and the easiest way would be to simply exclude columns used as measure.vars. However, I seem to be unable to this.
I have also tried:
ids<-df1[,-c(msr)] #why can't I exclude?
melt(df1,
id.vars = c(ids), #problem here
measure.vars = c(msr))
Any suggestions?