[R] acast: how to obtain names?
marius.hofert at math.ethz.ch
Fri Nov 18 10:19:25 CET 2011
After applying acast() I typically have to adjust the names of the array by hand. Is there any way to tell acast to do this automatically?
(df <- data.frame(a=c("a1","a2"), b=c("b1","b2"), c=c("c1","c2")))
a.df <- acast(df, a~b, value_var="c")
names(dimnames(a.df)) # => NULL; would be nice to get the following:
names(dimnames(a.df)) <- c("a", "b")
More information about the R-help