2015-01-20 65 views
0

我想下面寫的tidyr::spread呼叫的reshape2::dcast如何使用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

您可以使用此方法的術語:

library(reshape2) 
dcast(stocksm, stock ~ time) 
相關問題