我想根据tidyr::spread
reshape2::dcast
来电
stocks <- data.frame(
time = as.Date('2009-01-01') + 0:9,
X = rnorm(10, 0, 1),
Y = rnorm(10, 0, 2),
Z = rnorm(10, 0, 4)
)
stocksm <- stocks %>% gather(stock, price, -time)
stocksm %>% spread(time, price)
我无法确定要传递给fun.aggregate
答案 0 :(得分:0)
您可以使用此方法:
library(reshape2)
dcast(stocksm, stock ~ time)