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

parse_guess(..., guess_integer = TRUE) invalid for large integers? #1407

Open
msberends opened this issue Jun 17, 2022 · 5 comments
Open

parse_guess(..., guess_integer = TRUE) invalid for large integers? #1407

msberends opened this issue Jun 17, 2022 · 5 comments
Labels
bug an unexpected problem or unintended behavior col_types 🏥

Comments

@msberends
Copy link

msberends commented Jun 17, 2022

Hi,

Thanks for the package. If I want to parse large whole numbers, I cannot get them to get imported as integers if I set guess_integer = TRUE:

readr::parse_guess(x = as.character(49555598868235), guess_integer = FALSE)
#> [1] 4.95556e+13
readr::parse_guess(x = as.character(49555598868235), guess_integer = TRUE)
#> [1] 266206987

Created on 2022-06-21 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.0 (2022-04-22)
#>  os       macOS Big Sur/Monterey 10.16
#>  system   x86_64, darwin17.0
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Amsterdam
#>  date     2022-06-21
#>  pandoc   2.17.1.1 @ /Applications/RStudio.app/Contents/MacOS/quarto/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cli           3.3.0   2022-04-25 [1] CRAN (R 4.2.0)
#>  crayon        1.5.1   2022-03-26 [1] CRAN (R 4.2.0)
#>  digest        0.6.29  2021-12-01 [1] CRAN (R 4.2.0)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.2.0)
#>  evaluate      0.15    2022-02-18 [1] CRAN (R 4.2.0)
#>  fansi         1.0.3   2022-03-24 [1] CRAN (R 4.2.0)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.2.0)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.2.0)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.2.0)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.2.0)
#>  hms           1.1.1   2021-09-26 [1] CRAN (R 4.2.0)
#>  htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.2.0)
#>  knitr         1.39    2022-04-26 [1] CRAN (R 4.2.0)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.2.0)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.2.0)
#>  pillar        1.7.0   2022-02-01 [1] CRAN (R 4.2.0)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.2.0)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.2.0)
#>  R.cache       0.15.0  2021-04-30 [1] CRAN (R 4.2.0)
#>  R.methodsS3   1.8.1   2020-08-26 [1] CRAN (R 4.2.0)
#>  R.oo          1.24.0  2020-08-26 [1] CRAN (R 4.2.0)
#>  R.utils       2.11.0  2021-09-26 [1] CRAN (R 4.2.0)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.2.0)
#>  readr         2.1.2   2022-01-30 [1] CRAN (R 4.2.0)
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.2.0)
#>  rlang         1.0.2   2022-03-04 [1] CRAN (R 4.2.0)
#>  rmarkdown     2.14    2022-04-25 [1] CRAN (R 4.2.0)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.2.0)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.2.0)
#>  stringi       1.7.6   2021-11-29 [1] CRAN (R 4.2.0)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.2.0)
#>  styler        1.7.0   2022-03-13 [1] CRAN (R 4.2.0)
#>  tibble        3.1.6   2021-11-07 [1] CRAN (R 4.2.0)
#>  tzdb          0.3.0   2022-03-28 [1] CRAN (R 4.2.0)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.2.0)
#>  vctrs         0.4.1   2022-04-13 [1] CRAN (R 4.2.0)
#>  withr         2.5.0   2022-03-03 [1] CRAN (R 4.2.0)
#>  xfun          0.30    2022-03-02 [1] CRAN (R 4.2.0)
#>  yaml          2.3.5   2022-02-21 [1] CRAN (R 4.2.0)
#> 
#>  [1] /Users/msberends/Library/R/4.2/library
#>  [2] /Library/Frameworks/R.framework/Versions/4.2/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

The second result should probably be an <int64>? I might not be too familiar with the difference between 32 bit and 64 integers, but the documentation says:

guess_integer If TRUE, guess integer types for whole numbers, if FALSE guess numeric type for all numbers`

So I assumed to get integers as my input is a whole number.

@williamlai2
Copy link

What version a re you using?

Doesn't seem to be an issue for me (on 2.0.1):

> readr::parse_guess(x = as.character(49555598868235), guess_integer = FALSE)
[1] 4.95556e+13
> readr::parse_guess(x = as.character(49555598868235), guess_integer = TRUE)
[1] 4.95556e+13
> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

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

loaded via a namespace (and not attached):
 [1] fansi_1.0.3       withr_2.5.0       tzdb_0.1.2        utf8_1.2.2        crayon_1.5.1      digest_0.6.29     R6_2.5.1          lifecycle_1.0.1  
 [9] magrittr_2.0.3    evaluate_0.14     pillar_1.7.0      rlang_1.0.2       cli_3.3.0         vctrs_0.4.1       ellipsis_0.3.2    rmarkdown_2.14   
[17] tools_4.1.1       readr_2.0.1       glue_1.6.2        hms_1.1.1         xfun_0.31         yaml_2.2.1        fastmap_1.1.0     compiler_4.1.1   
[25] pkgconfig_2.0.3   sessioninfo_1.1.1 htmltools_0.5.2   knitr_1.34        tibble_3.1.7     

@msberends
Copy link
Author

msberends commented Jun 21, 2022

I am actually on a more recent version: readr 2.1.2, using R 4.2.0 on macOS.

I updated my first post to include the session info.

@williamlai2
Copy link

I've updated mine to 2.1.2 as well now and it seems to be fine for me. Hopefully someone can fix it.

@RoyalTS
Copy link

RoyalTS commented Aug 4, 2022

Same issue for me on 2.1.2. If this worked fine in 2.0.1, which was released in August 2021, did one of @jimhester's changes late last year inadvertently break this?

@sbearrows sbearrows added bug an unexpected problem or unintended behavior collector labels Aug 25, 2022
@hadley
Copy link
Member

hadley commented Jul 31, 2023

I can reproduce this too:

library(readr)

parse_guess("49555598868235", guess_integer = FALSE)
#> [1] 4.95556e+13
parse_guess("49555598868235", guess_integer = TRUE)
#> [1] 266206987

parse_integer("49555598868235")
#> [1] 266206987

Created on 2023-07-31 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior col_types 🏥
Projects
None yet
Development

No branches or pull requests

5 participants