我正在尝试从我创建的数据框列表中编写一个 xlsx 文件,但由于缺少数据(我无法下载它)而出现错误。除了缺少数据之外,我只想编写 xlsx 文件。任何帮助表示赞赏。
对于问题的复制:
library(quantmod)
name_of_symbols <- c("AKER","YECO","SNOA")
research_dates <- c("2018-11-19","2018-11-19","2018-11-14")
my_symbols_df <- lapply(name_of_symbols, function(x) tryCatch(getSymbols(x, auto.assign = FALSE),error = function(e) { }))
my_stocks_OHLCV <- list()
for (i in 1:3) {
trade_date <- paste(as.Date(research_dates[i]))
OHLCV_data <- my_symbols_df[[i]][trade_date]
my_stocks_OHLCV[[i]] <- data.frame(OHLCV_data)
}
你可以在这里看到丢失的数据my_stocks_OHLCV[[2]]
和write.xlsx
我得到的错误:
print(my_stocks_OHLCV)
[[1]]
AKER.Open AKER.High AKER.Low AKER.Close AKER.Volume AKER.Adjusted
2018-11-19 2.67 3.2 1.56 1.75 15385800 1.75
[[2]]
data frame with 0 columns and 0 rows
[[3]]
SNOA.Open SNOA.High SNOA.Low SNOA.Close SNOA.Volume SNOA.Adjusted
2018-11-14 1.1 1.14 1.01 1.1 107900 1.1
write.xlsx(my_stocks_OHLCV, "C:/Users/MICRO/Downloads/Datasets_stocks/dux_OHLCV.xlsx") Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,:arguments imply differing number of rows: 1, 0
即使我有这些丢失的数据,我如何运行 write.xlsx?