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

is.numeric() returns TRUE for Duration, Period and Interval objects #942

Closed
danielvartan opened this issue Jan 9, 2021 · 2 comments
Closed

Comments

@danielvartan
Copy link

danielvartan commented Jan 9, 2021

Problem: when placed in is.numeric(), Duration, Period and Interval objects return TRUE.

I don't know if this was intentional, but it is very annoying.

Reprex

is.numeric(lubridate::dhours())
#> [1] TRUE
is.numeric(lubridate::hours())
#> [1] TRUE
is.numeric(lubridate::as.interval(lubridate::dhours(), lubridate::ymd("2021-01-01")))
#> [1] TRUE
is.numeric(lubridate::as.difftime(lubridate::dhours()))
#> [1] FALSE
is.numeric(hms::parse_hm("10:00"))
#> [1] FALSE
is.numeric(lubridate::as_date("2021-01-01"))
#> [1] FALSE
is.numeric(lubridate::ymd_hms("2021-01-01 01:00:00"))
#> [1] FALSE

base::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=Portuguese_Brazil.1252 
[2] LC_CTYPE=Portuguese_Brazil.1252   
[3] LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C                      
[5] LC_TIME=Portuguese_Brazil.1252    

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

other attached packages:
[1] reprex_0.3.0      lubridate_1.7.9.2 devtools_2.3.2   
[4] usethis_2.0.0    

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5        compiler_4.0.2    pillar_1.4.7     
 [4] prettyunits_1.1.1 remotes_2.2.0     tools_4.0.2      
 [7] testthat_2.3.2    digest_0.6.25     pkgbuild_1.2.0   
[10] pkgload_1.1.0     memoise_1.1.0     evaluate_0.14    
[13] lifecycle_0.2.0   tibble_3.0.4      pkgconfig_2.0.3  
[16] rlang_0.4.7       cli_2.2.0         rstudioapi_0.13  
[19] yaml_2.2.1        xfun_0.17         knitr_1.30       
[22] withr_2.3.0       desc_1.2.0        generics_0.1.0   
[25] fs_1.5.0          vctrs_0.3.6       rprojroot_2.0.2  
[28] glue_1.4.2        R6_2.5.0          processx_3.4.4   
[31] fansi_0.4.1       rmarkdown_2.6     sessioninfo_1.1.1
[34] whisker_0.4       callr_3.5.1       purrr_0.3.4      
[37] clipr_0.7.1       magrittr_2.0.1    htmltools_0.5.0  
[40] ps_1.3.4          ellipsis_0.3.1    assertthat_0.2.1 
[43] crayon_1.3.4  

devtools::session_info()

- Session info ---------------------------------------------------
 setting  value                       
 version  R version 4.0.2 (2020-06-22)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  Portuguese_Brazil.1252      
 ctype    Portuguese_Brazil.1252      
 tz       America/Sao_Paulo           
 date     2021-01-08                  

- Packages -------------------------------------------------------
 package     * version date       lib source        
 assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.0.3)
 callr         3.5.1   2020-10-13 [1] CRAN (R 4.0.3)
 cli           2.2.0   2020-11-20 [1] CRAN (R 4.0.3)
 clipr         0.7.1   2020-10-08 [1] CRAN (R 4.0.3)
 crayon        1.3.4   2017-09-16 [1] CRAN (R 4.0.3)
 desc          1.2.0   2018-05-01 [1] CRAN (R 4.0.2)
 devtools    * 2.3.2   2020-09-18 [1] CRAN (R 4.0.3)
 digest        0.6.25  2020-02-23 [1] CRAN (R 4.0.2)
 ellipsis      0.3.1   2020-05-15 [1] CRAN (R 4.0.2)
 evaluate      0.14    2019-05-28 [1] CRAN (R 4.0.2)
 fansi         0.4.1   2020-01-08 [1] CRAN (R 4.0.2)
 fs            1.5.0   2020-07-31 [1] CRAN (R 4.0.2)
 generics      0.1.0   2020-10-31 [1] CRAN (R 4.0.3)
 glue          1.4.2   2020-08-27 [1] CRAN (R 4.0.2)
 htmltools     0.5.0   2020-06-16 [1] CRAN (R 4.0.2)
 knitr         1.30    2020-09-22 [1] CRAN (R 4.0.2)
 lifecycle     0.2.0   2020-03-06 [1] CRAN (R 4.0.2)
 lubridate   * 1.7.9.2 2020-11-13 [1] CRAN (R 4.0.3)
 magrittr      2.0.1   2020-11-17 [1] CRAN (R 4.0.3)
 memoise       1.1.0   2017-04-21 [1] CRAN (R 4.0.2)
 pillar        1.4.7   2020-11-20 [1] CRAN (R 4.0.3)
 pkgbuild      1.2.0   2020-12-15 [1] CRAN (R 4.0.3)
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.0.2)
 pkgload       1.1.0   2020-05-29 [1] CRAN (R 4.0.3)
 prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.0.2)
 processx      3.4.4   2020-09-03 [1] CRAN (R 4.0.2)
 ps            1.3.4   2020-08-11 [1] CRAN (R 4.0.2)
 purrr         0.3.4   2020-04-17 [1] CRAN (R 4.0.2)
 R6            2.5.0   2020-10-28 [1] CRAN (R 4.0.3)
 Rcpp          1.0.5   2020-07-06 [1] CRAN (R 4.0.2)
 remotes       2.2.0   2020-07-21 [1] CRAN (R 4.0.2)
 reprex      * 0.3.0   2019-05-16 [1] CRAN (R 4.0.3)
 rlang         0.4.7   2020-07-09 [1] CRAN (R 4.0.2)
 rmarkdown     2.6     2020-12-14 [1] CRAN (R 4.0.3)
 rprojroot     2.0.2   2020-11-15 [1] CRAN (R 4.0.3)
 rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.0.3)
 sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.0.2)
 testthat      2.3.2   2020-03-02 [1] CRAN (R 4.0.2)
 tibble        3.0.4   2020-10-12 [1] CRAN (R 4.0.3)
 usethis     * 2.0.0   2020-12-10 [1] CRAN (R 4.0.3)
 vctrs         0.3.6   2020-12-17 [1] CRAN (R 4.0.3)
 whisker       0.4     2019-08-28 [1] CRAN (R 4.0.2)
 withr         2.3.0   2020-09-22 [1] CRAN (R 4.0.2)
 xfun          0.17    2020-09-09 [1] CRAN (R 4.0.2)
 yaml          2.2.1   2020-02-01 [1] CRAN (R 4.0.2)

[1] C:/Users/Daniel/Documents/R/win-library/4.0
[2] C:/Program Files/R/R-4.0.2/library
@danielvartan danielvartan changed the title is.numeric() returns TRUE for Duration, Period and Interval objects is.numeric() returns TRUE for Duration, Period and Interval objects Jan 9, 2021
@vspinu
Copy link
Member

vspinu commented Jan 9, 2021

Unfortunate but cannot be changed. Only if lubridate is rewritten from scratch I am afraid.

@danielvartan
Copy link
Author

☹ . That's ok. Thanks for the answer.

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

No branches or pull requests

2 participants