In this code:
library(tidyr)
dat<-data.frame(var=letters[1:13],value=runif(13))
dat
spread(dat, var, value)
dat$dummy=1
spread(dat, var, value)
Why should the first spread() give me a 13 row data frame (with the values on the trace), while the second gives me a single row (which is what I wanted in the first place)?
Of course, with reshape2 I'd have to specify the dummy explicitly:
library(reshape2)
dat<-data.frame(var=letters[1:13],value=runif(13))
dat
dcast(dat, 1~var, value.var = "value")
... or use the special '.' syntax
dcast(dat, .~var, value.var = "value")
... but even the "..." syntax does what I wanted, and is closest to my first spread() above.
dcast(dat, ...~var, value.var = "value")
I guess my question is why the 13 row data frame makes sense. Or perhaps it doesn't and I should file an issue?
Best,
-J