Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complex xts objects #346

Closed
ggrothendieck opened this issue Jan 9, 2021 · 3 comments
Closed

complex xts objects #346

ggrothendieck opened this issue Jan 9, 2021 · 3 comments
Assignees
Labels
Milestone

Comments

@ggrothendieck
Copy link

ggrothendieck commented Jan 9, 2021

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))
@joshuaulrich joshuaulrich self-assigned this Jan 9, 2021
@joshuaulrich
Copy link
Owner

Thanks for the report! I'll take a look.

@joshuaulrich
Copy link
Owner

joshuaulrich commented Jan 18, 2021

Here's a minimal reproducible example:

library(xts)
data(sample_matrix)

x <- as.xts(sample_matrix) 
y <- x[1:5,1] * 1i
z <- x[3:9,4] * 1i
a <- merge(y, z)
# Error in merge.xts(y, z) : 
#   REAL() can only be applied to a 'numeric', not a 'complex'

@ggrothendieck
Copy link
Author

Regarding the quantmod example what would be nice would be if a column could contain the entire OHLCV rather than just close and volulme. Would it be feasible to support a new tuple type that is like complex except it would allow each column to contain multiple columns, not just 2 like complex does.

@joshuaulrich joshuaulrich added this to the 0.12.2 milestone Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants