Closed
Description
This gives an error:
library(quantmod)
tickers <- c("AAPL", "TSLA")
getSymbols(tickers, env = stocks <- new.env())
L <- eapply(stocks, function(x) Cl(x) + Vo(x) * 1i)
res <- do.call("cbind", L)
## Error in merge.xts(..., all = all, fill = fill, suffixes = suffixes) :
## REAL() can only be applied to a 'numeric', not a 'complex'
If we convert to zoo and back then we do not get any errors:
library(quantmod)
tickers <- c("AAPL", "TSLA")
getSymbols(tickers, env = stocks <- new.env())
L <- eapply(stocks, function(x) Cl(as.zoo(x)) + Vo(as.zoo(x)) * 1i)
res <- as.xts(do.call("cbind", L))