joshuaulrich/xts

period.apply on xts object takes about 50x longer than running it on it's core data and recasting.

オープン

#278 opened on 2018/11/02

 (10 件のコメント) (0 件のリアクション) (0 人の担当者)R (72 件のフォーク)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (224 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

Description

on large xts objects +1MM lines, period.apply is much faster using core data and recasting

Expected behavior

about equal runtimes with and without a numeric index

Minimal, reproducible example

n <- 1e6
ep <- seq(1, n, 3) 
x <- .xts(runif(n, 1, n), 1:n)
system.time(test1 <- period.apply(x, ep, sum)) 
#    user  system elapsed
#  12.637   0.010  12.653
system.time(test2 <- period.apply(coredata(x), ep, sum)) 
#    user  system elapsed
#   0.803   0.000   0.804

Session Info

R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS

Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    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] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] Rcpp_0.12.19               roll_1.0.7                 forecast_8.4               DEoptim_2.2-4              dygraphs_1.1.1.6           PerformanceAnalytics_1.5.2 FinancialInstrument_1.3.1  quantmod_0.4-13            TTR_0.23-3                
[10] xts_0.11-1                 zoo_1.8-3                 

loaded via a namespace (and not attached):
 [1] uroot_2.0-9          lattice_0.20-35      assertthat_0.2.0     digest_0.6.15        lmtest_0.9-36        mime_0.5             R6_2.2.2             plyr_1.8.4           backports_1.1.2      futile.options_1.0.1 ggplot2_3.0.0       
[12] pillar_1.2.3         rlang_0.3.0          uuid_0.1-2           lazyeval_0.2.1       curl_3.2             misc3d_0.8-4         data.table_1.11.4    fracdiff_1.4-2       R.utils_2.6.0        R.oo_1.22.0          checkmate_1.8.5     
[23] stringr_1.3.1        pander_0.6.2         htmlwidgets_0.9      RCurl_1.95-4.10      munsell_0.5.0        shiny_1.0.5          compiler_3.5.1       httpuv_1.4.4.2       pkgconfig_2.0.1      qmao_1.6.11          urca_1.3-0          
[34] htmltools_0.3.6      nnet_7.3-12          tidyselect_0.2.5     htmlTable_1.9        tibble_1.4.2         quadprog_1.5-5       dplyr_0.7.7          later_0.7.3          bitops_1.0-6         R.methodsS3_1.7.1    grid_3.5.1          
[45] nlme_3.1-137         jsonlite_1.5         xtable_1.8-2         gtable_0.2.0         formatR_1.5          magrittr_1.5         scales_0.5.0         RcppParallel_4.4.1   stringi_1.2.3        promises_1.0.1       tseries_0.10-45     
[56] bindrcpp_0.2.2       timeDate_3043.102    futile.logger_1.4.3  plot3D_1.1.1         lambda.r_1.2.3       tools_3.5.1          RJSONIO_1.3-0        glue_1.3.0           purrr_0.2.5          yaml_2.1.19          colorspace_1.3-2    
[67] knitr_1.20           bindr_0.1.1          profvis_0.3.5       

コントリビューターガイド