我有一个包含6个列的小标题,第6列包含一个小标题列表。其他列的类型为double或character。如果我在小标题上应用unnest(),则会收到下一个错误:
错误:每列必须是矢量列表或数据帧列表[stock.prices]
library(multidplyr)
library(tidyquant)
library(parallel)
start.time <- Sys.time()
sp_500 <- tq_index("SP500")
sp_500[(sp_500$symbol =="BRK.B"),]$symbol <- "BRK-B"
sp_500[(sp_500$symbol =="BF.B"),]$symbol <- "BF-B"
from <- "2017-01-01"
to <- today()
cl <- detectCores()
group <- rep(1:cl, length.out = nrow(sp_500))
sp_500 <- bind_cols(data.frame(group), sp_500)
cluster <- create_cluster(cores = cl)
by_group <- sp_500 %>%
partition(group, cluster = cluster)
by_group %>%
cluster_library("tidyquant") %>%
cluster_assign_value("from", from) %>%
cluster_assign_value("to", to)
sp_500_precios <- by_group %>%
mutate(stock.prices = map(symbol, function(.x) tq_get(.x, get =
"stock.prices", from = from, to = to))) %>%
collect() %>%
unnest()
stopCluster(cluster)
end.time <- Sys.time()
time.taken <- end.time - start.time
time.taken
data.frame(sp_500_precios)
有人知道如何解决这个问题吗?
谢谢;)