How to use acast (reshape2) within a function in R?
问题 I tried to use acast from reshape2 within a self written function, but had the problem that acast did not find the data I send to it. Here is my data: library("reshape2") x <- data.frame(1:3, rnorm(3), rnorm(3), rnorm(3)) colnames(x) <- c("id", "var1", "var2", "var3") y <-melt(x, id = "id", measure = c("var1", "var2", "var3")) y then looks like this: id variable value 1 1 var1 0.1560812 2 2 var1 1.0343844 3 3 var1 -1.4157728 4 1 var2 0.8808935 5 2 var2 0.1719239 6 3 var2 0.6723758 7 1 var3 -0