joshuaulrich / TTR

Technical analysis and other functions to construct technical trading rules with R
GNU General Public License v2.0
325 stars 102 forks source link

rename output column in TTR::ROC #105

Open ethanbsmith opened 3 years ago

ethanbsmith commented 3 years ago

Description

ROC currently names the return value the same as the input value. most other TTR function explicitly name output columns

Expected behavior

output column should be names roc

I think adding this line at line 75 in changes.R will produce the desired result, but it is a breaking change: if (!is.null(dim(roc))) colnames(roc) <- "roc"

Minimal, reproducible example

 tail(TTR::ROC(Cl(getSymbols("SPY"))),3)
#                                       Close
#2020-Sep-17 00:00:00.000  -0600 -0.008834137
#2020-Sep-18 00:00:00.000  -0600 -0.011532346
#2020-Sep-21 00:00:00.000  -0600 -0.011191991

Session Info

sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C                           LC_TIME=English_United States.1252    

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

other attached packages:
 [1] rollRegres_0.1.3  rio_0.5.16        rvest_0.3.6       xml2_1.3.2        reticulate_1.16   data.table_1.13.1 curl_4.3          quantmod_0.4.17   TTR_0.24.2        xts_0.12.1        zoo_1.8-8        
[12] RODBC_1.3-17      doParallel_1.0.15 iterators_1.0.12  foreach_1.5.0     plotrix_3.7-8     checkpoint_0.4.9 

loaded via a namespace (and not attached):
 [1] zip_2.1.1        Rcpp_1.0.5       cellranger_1.1.0 compiler_4.0.2   pillar_1.4.6     forcats_0.5.0    tools_4.0.2      checkmate_2.0.0  jsonlite_1.7.1   tibble_3.0.3     lifecycle_0.2.0  lattice_0.20-41 
[13] pkgconfig_2.0.3  rlang_0.4.7      openxlsx_4.1.5   Matrix_1.2-18    rstudioapi_0.11  haven_2.3.1      httr_1.4.2       vctrs_0.3.4      hms_0.5.3        grid_4.0.2       R6_2.4.1         readxl_1.3.1    
[25] foreign_0.8-80   magrittr_1.5     backports_1.1.9  codetools_0.2-16 ellipsis_0.3.1   stringi_1.5.3    crayon_1.3.4