0

I have a list of 31 data frames (split_data_V3.0) that I am trying to convert to xts object using lapply. The code gets executed but when I try to open the elements from the new lists (split_data_V3.0_zoo, split_data_V3.0_xts) I get the error message "Error in names[[i]] : subscript out of bounds". Could someone help with this ?

grouping <- data_V3.0_csv$Symbol
split_data_V3.0 <- split(data_V3.0_csv, grouping)

split_data_V3.0_zoo <- lapply(split_data_V3.0, function (x) read.zoo(x, index.column = c("X")))
split_data_V3.0_xts <- lapply(split_data_V3.0_zoo, function(x) as.xts(x))

Error message:

 split_data_V3.0_zoo <- lapply(split_data_V3.0, function (x) read.zoo(x, index.column = c("X")))
> split_data_V3.0_xts <- lapply(split_data_V3.0_zoo, function(x) as.xts(x))
> View(split_data_V3.0_zoo)
> View(split_data_V3.0_xts)
Error in names[[i]] : subscript out of bounds
Error in names[[i]] : subscript out of bounds
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
  • I also tried with this, but I get the same: ```indices_df_transform <- function(symbol){ symbol_zoo <- read.zoo(symbol, index.column = c("X")) as.xts(symbol_zoo) } split_data_V3.0_xts <- lapply(split_data_V3.0, indices_df_transform)``` – Bianca Schley Sep 02 '20 at 16:08
  • It would be easier to help if you create a small reproducible example along with expected output. Read about [how to give a reproducible example](http://stackoverflow.com/questions/5963269). – Ronak Shah Jun 06 '21 at 02:28

0 Answers0