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

rollapply #399

Open
ggrothendieck opened this issue Apr 10, 2023 · 1 comment
Open

rollapply #399

ggrothendieck opened this issue Apr 10, 2023 · 1 comment

Comments

@ggrothendieck
Copy link

ggrothendieck commented Apr 10, 2023

This fails if as.zoo is removed.

# https://stackoverflow.com/questions/75954700/75978704#75978704
library(quantmod)
getSymbols("SPY")
SPY.Close <- Ad(SPY)

SPY.Close$dn3 <- +rollapplyr(diff(as.zoo(SPY.Close)) < 0, 3, identical, 
  c(TRUE, TRUE, TRUE), fill = NA)
@joshuaulrich
Copy link
Owner

joshuaulrich commented Apr 10, 2023

It fails for me even with the as.zoo().

SPY.Close$dn3 <- +rollapplyr(diff(as.zoo(SPY.Close)) < 0, 3, identical, 
    c(TRUE, TRUE, TRUE), fill = NA)
## Error in NextMethod(.Generic) : 
##   number of items to replace is not a multiple of replacement length

What's your sessionInfo()?

R$ sessionInfo()
R version 4.2.2 Patched (2022-11-10 r83330)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] quantmod_0.4.22 TTR_0.24.3      xts_0.13.0      zoo_1.8-11      colorout_1.2-2 

loaded via a namespace (and not attached):
[1] compiler_4.2.2  tools_4.2.2     curl_5.0.0      grid_4.2.2      jsonlite_1.8.4 
[6] lattice_0.20-45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants