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

Strange result tk_make_timeseries() using by = "8 day" as an argument #60

Closed
luifrancgom opened this issue Sep 28, 2020 · 3 comments
Closed

Comments

@luifrancgom
Copy link

@luifrancgom luifrancgom commented Sep 28, 2020

Hello Matt Dancho

I am exploring the function tk_make_timeseries() using version 2.3.0 of the package timetk and I get the following result when using tk_make_timeseries(start_date = "2011-01-01", by = "8 day", length_out = 10) where I attach information about my session:

library(timetk)
sessionInfo()
#> R version 4.0.2 (2020-06-22)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=es_CO.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=es_CO.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=es_CO.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=es_CO.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] timetk_2.3.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] zoo_1.8-8          tidyselect_1.1.0   xfun_0.17          purrr_0.3.4       
#>  [5] listenv_0.8.0      splines_4.0.2      lattice_0.20-41    colorspace_1.4-1  
#>  [9] vctrs_0.3.4        generics_0.0.2     htmltools_0.5.0    rsample_0.0.8     
#> [13] yaml_2.2.1         survival_3.1-12    prodlim_2019.11.13 rlang_0.4.7       
#> [17] pillar_1.4.6       glue_1.4.2         withr_2.3.0        lifecycle_0.2.0   
#> [21] lava_1.6.8         stringr_1.4.0      timeDate_3043.102  munsell_0.5.0     
#> [25] gtable_0.3.0       future_1.19.1      recipes_0.1.13     codetools_0.2-16  
#> [29] evaluate_0.14      knitr_1.30         parallel_4.0.2     class_7.3-17      
#> [33] highr_0.8          furrr_0.1.0        xts_0.12.1         Rcpp_1.0.5        
#> [37] scales_1.1.1       ipred_0.9-9        ggplot2_3.3.2      digest_0.6.25     
#> [41] stringi_1.5.3      dplyr_1.0.2        grid_4.0.2         tools_4.0.2       
#> [45] magrittr_1.5       tibble_3.0.3       crayon_1.3.4       tidyr_1.1.2       
#> [49] pkgconfig_2.0.3    MASS_7.3-53        ellipsis_0.3.1     Matrix_1.2-18     
#> [53] lubridate_1.7.9    gower_0.2.2        rmarkdown_2.3      R6_2.4.1          
#> [57] globals_0.13.0     rpart_4.1-15       nnet_7.3-14        compiler_4.0.2

tk_make_timeseries(start_date = "2011-01-01",
                   by         = "8 day",
                   length_out = 10)
#>  [1] "2011-01-01" "2010-12-31" "2010-12-31" "2010-12-31" "2011-01-31"
#>  [6] "2011-01-31" "2011-01-31" "2011-01-31" "2011-02-28" "2011-02-28"

Created on 2020-09-28 by the reprex package (v0.3.0)

The time stamp jump from 2011-01-01 to 2010-12-31

However I don't have the same problem with by = "1 day", by = "2 day", ..., by = "7 day". For example with tk_make_timeseries(start_date = "2011-01-01", by = "7 day", length_out = 10):

library(timetk)
sessionInfo()
#> R version 4.0.2 (2020-06-22)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=es_CO.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=es_CO.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=es_CO.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=es_CO.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] timetk_2.3.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] zoo_1.8-8          tidyselect_1.1.0   xfun_0.17          purrr_0.3.4       
#>  [5] listenv_0.8.0      splines_4.0.2      lattice_0.20-41    colorspace_1.4-1  
#>  [9] vctrs_0.3.4        generics_0.0.2     htmltools_0.5.0    rsample_0.0.8     
#> [13] yaml_2.2.1         survival_3.1-12    prodlim_2019.11.13 rlang_0.4.7       
#> [17] pillar_1.4.6       glue_1.4.2         withr_2.3.0        lifecycle_0.2.0   
#> [21] lava_1.6.8         stringr_1.4.0      timeDate_3043.102  munsell_0.5.0     
#> [25] gtable_0.3.0       future_1.19.1      recipes_0.1.13     codetools_0.2-16  
#> [29] evaluate_0.14      knitr_1.30         parallel_4.0.2     class_7.3-17      
#> [33] highr_0.8          furrr_0.1.0        xts_0.12.1         Rcpp_1.0.5        
#> [37] scales_1.1.1       ipred_0.9-9        ggplot2_3.3.2      digest_0.6.25     
#> [41] stringi_1.5.3      dplyr_1.0.2        grid_4.0.2         tools_4.0.2       
#> [45] magrittr_1.5       tibble_3.0.3       crayon_1.3.4       tidyr_1.1.2       
#> [49] pkgconfig_2.0.3    MASS_7.3-53        ellipsis_0.3.1     Matrix_1.2-18     
#> [53] lubridate_1.7.9    gower_0.2.2        rmarkdown_2.3      R6_2.4.1          
#> [57] globals_0.13.0     rpart_4.1-15       nnet_7.3-14        compiler_4.0.2

tk_make_timeseries(start_date = "2011-01-01",
                   by         = "7 day",
                   length_out = 10)
#>  [1] "2011-01-01" "2011-01-08" "2011-01-15" "2011-01-22" "2011-01-29"
#>  [6] "2011-02-05" "2011-02-12" "2011-02-19" "2011-02-26" "2011-03-05"

Created on 2020-09-28 by the reprex package (v0.3.0)

I get the correct time stamps

@mdancho84
Copy link
Contributor

@mdancho84 mdancho84 commented Sep 29, 2020

Thank you for the reproducible example. I'm investigating.

@mdancho84
Copy link
Contributor

@mdancho84 mdancho84 commented Sep 29, 2020

This should be fixed now.

library(tidyverse)
library(timetk)

tk_make_timeseries(start_date = "2011-01-01",
                   by         = "8 day",
                   length_out = 10)
#>  [1] "2011-01-01" "2011-01-09" "2011-01-17" "2011-01-25" "2011-02-02"
#>  [6] "2011-02-10" "2011-02-18" "2011-02-26" "2011-03-06" "2011-03-14"

Created on 2020-09-29 by the reprex package (v0.3.0)

@mdancho84 mdancho84 closed this in c64e5d3 Sep 29, 2020
@mdancho84
Copy link
Contributor

@mdancho84 mdancho84 commented Sep 29, 2020

This will be added to version timetk 2.4.0 when it goes to CRAN. It's fixed in the development version.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.