What is the best way to handle this issue? Is it to store the stock$Volume as a temporary object where NA values are removed and then calculate the rolling volume and the merge it back in with merge.xts while adding the fill = NA so NA values are inserted again? But is that correct since you take the last 20 trading days and not just the 19 available in the 20-day window? functions in TTR cannot handle NAs if they are preceded by numbers and followed by numbers. I have reproduced those days' data below. I quickly located the problem (which I knew was NA values since I have tried this a 1000 times) and found the two days where volume data is missing. When I want to calculate rolling 20-day volume the error message occurs: SMA(stock$Volume, 20)Įrror in runSum(x, n) : Series contains non-leading NAs The example below is about a stock with EOD data since stored in a xts object with four columns named "High","Low","Close","Volume". There is a binary version available but the source version is later:Ĭontent type 'application/zip' length 2630748 bytes (2.5 MB)Ĭontent type 'application/zip' length 1255891 bytes (1.2 MB)Ĭontent type 'application/zip' length 150020 bytes (146 KB)Ĭontent type 'application/zip' length 1512678 bytes (1.4 MB)Ĭontent type 'application/zip' length 62511 bytes (61 KB)Ĭontent type 'application/zip' length 123975 bytes (121 KB)Ĭontent type 'application/zip' length 244779 bytes (239 KB)Ĭontent type 'application/zip' length 84265 bytes (82 KB)Ĭontent type 'application/zip' length 55837 bytes (54 KB)Ĭontent type 'application/zip' length 1300050 bytes (1.2 MB)Ĭontent type 'application/zip' length 312926 bytes (305 KB)Ĭontent type 'application/zip' length 227233 bytes (221 KB)Ĭontent type 'application/zip' length 690299 bytes (674 KB)Ĭontent type 'application/zip' length 22543 bytes (22 KB)Ĭontent type 'application/zip' length 1298450 bytes (1.2 MB)Ĭontent type 'application/zip' length 194544 bytes (189 KB)Ĭontent type 'application/zip' length 161942 bytes (158 KB)Ĭontent type 'application/zip' length 164303 bytes (160 KB)Ĭontent type 'application/zip' length 2179273 bytes (2.1 MB)Ĭontent type 'application/zip' length 1574793 bytes (1.5 MB)Ĭontent type 'application/zip' length 614865 bytes (600 KB)Ĭontent type 'application/zip' length 733228 bytes (716 KB)Ĭontent type 'application/zip' length 231532 bytes (226 KB)Ĭontent type 'application/zip' length 4124220 bytes (3.I often run into the same issue of how to handle NA values when modelling quantitative trading models. > Installing package into ‘C:/Users/sarac/AppData/Local/R/win-library/4.2’Īlso installing the dependencies ‘colorspace’, ‘cli’, ‘utf8’, ‘farver’, ‘labeling’, ‘lifecycle’, ‘munsell’, ‘R6’, ‘RColorBrewer’, ‘viridisLite’, ‘fansi’, ‘magrittr’, ‘pillar’, ‘pkgconfig’, ‘vctrs’, ‘digest’, ‘glue’, ‘gtable’, ‘isoband’, ‘rlang’, ‘scales’, ‘tibble’, ‘withr’ > Please download and install the appropriate version of Rtools before proceeding: Note that the following incompatible version(s) of Rtools were found: WARNING: Rtools is required to build R packages but no version of Rtools compatible with the currently running version of R was found. I have tried to install the file manually from a zip file but when I tried to load it would say the file was not valid. I have also tried to change the Primary CRAN repository from Global to one in the UK (which is where I am currently at). I have tried unticking the option in Tools> Global Options> Packages> Use secure download method for HTTP Installing the source packages ‘pillar’, ‘vctrs’, ‘scales’, ‘tibble’, ‘ggplot2’ Packages which are only available in source form, and may need compilation of C/C++/Fortran: ‘vctrs’ ‘tibble’ĭo you want to attempt to install these from sources? Installing package into ‘C:/Users/sarac/Documents/R/win-library/3.3’ĭependencies ‘glue’, ‘rlang’, ‘lifecycle’, ‘magrittr’, ‘cli’ are not availableĪlso installing the dependencies ‘pillar’, ‘vctrs’, ‘scales’, ‘tibble’ ‘C:\Users\sarac\AppData\Local\Temp\Rtmp6d0Bfu\downloaded_packages’ I cannot seem to be able to install ggplot 2 package. I have been trying to fix this for the past week.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |