joshuaulrich / quantmod

Quantitative Financial Modelling Framework
http://www.quantmod.com/
GNU General Public License v3.0
818 stars 224 forks source link

adjustOHLC - 'vapply' error #298

Closed HLatte closed 4 years ago

HLatte commented 4 years ago

Description

When running the example provided in the help page of 'adjustOHLC' I get the following error:

Error in vapply(parse(text = fr[, 2]), eval, numeric(1)) : values must be length 1, but FUN(X[[1]]) result is length 2

This happens with CRAN and developer versions.

Expected behaviour

to return an xts variable with the adjusted column

Minimal, reproducible example

getSymbols("AAPL", from="1990-01-01", src="yahoo")
head(AAPL.a <- adjustOHLC(AAPL))

Session Info

> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 

locale:
[1] LC_COLLATE=English_United Kingdom.1252 
[2] LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

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

other attached packages:
[1] PortfolioAnalytics_1.1.0   foreach_1.4.8             
[3] imputeTS_3.0               PerformanceAnalytics_2.0.4
[5] quantmod_0.4-15            TTR_0.23-6                
[7] xts_0.12-0                 zoo_1.8-7                 
[9] dplyr_0.8.4               

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3                lattice_0.20-38          
 [3] prettyunits_1.1.1         ps_1.3.2                 
 [5] rprojroot_1.3-2           assertthat_0.2.1         
 [7] digest_0.6.24             lmtest_0.9-37            
 [9] slam_0.1-47               R6_2.4.1                 
[11] backports_1.1.5           ROI.plugin.glpk_0.3-0    
[13] ggplot2_3.2.1             pillar_1.4.3             
[15] rlang_0.4.4               lazyeval_0.2.2           
[17] curl_4.3                  rstudioapi_0.11          
[19] fracdiff_1.5-1            callr_3.4.2              
[21] desc_1.2.0                devtools_2.2.2           
[23] ROI.plugin.quadprog_0.2-5 munsell_0.5.0            
[25] ROI_0.3-2                 compiler_3.6.2           
[27] pkgconfig_2.0.3           forecast_8.11            
[29] pkgbuild_1.0.6            urca_1.3-0               
[31] Rglpk_0.6-4               nnet_7.3-12              
[33] tidyselect_1.0.0          tibble_2.1.3             
[35] quadprog_1.5-8            codetools_0.2-16         
[37] fansi_0.4.1               withr_2.1.2              
[39] crayon_1.3.4              grid_3.6.2               
[41] nlme_3.1-144              gtable_0.3.0             
[43] lifecycle_0.1.0           registry_0.5-1           
[45] magrittr_1.5              scales_1.1.0             
[47] zip_2.0.4                 cli_2.0.1                
[49] stringi_1.4.5             fs_1.3.1                 
[51] remotes_2.1.1             tseries_0.10-47          
[53] testthat_2.3.1            timeDate_3043.102        
[55] ellipsis_0.3.0            openxlsx_4.1.4           
[57] iterators_1.0.12          tools_3.6.2              
[59] glue_1.3.1                purrr_0.3.3              
[61] processx_3.4.2            pkgload_1.0.2            
[63] parallel_3.6.2            colorspace_1.4-1         
[65] sessioninfo_1.1.1         stinepack_1.4            
[67] memoise_1.1.0             usethis_1.5.1            
joshuaulrich commented 4 years ago

This looks like a manifestation of #292. Can you try running with the last development version?

joshuaulrich commented 4 years ago

I cannot replicate this error, so I'm closing this as a duplicate of #292.