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

Feature request: warning message for numeric columns larger than 2^52 #1556

Open
huisunsh opened this issue Sep 27, 2024 · 0 comments
Open

Comments

@huisunsh
Copy link

huisunsh commented Sep 27, 2024

I know this issue has been raised before, for example, #976. When users call read_csv to import data without specifying the variable type of each column, read_csv does the smart trick and automatically identifies each column's variable type. All of these are wonderful, the only caveat is that numeric variables larger than 2^53-1 lost their precision.

> original_data <- tibble(project = c('10GS','23AS','11SG'), id = c(13101201211316084,13101200510130349,15103200910645447))
> write_csv(original_data, 'data.csv')
                                                                      
> data <- read_csv('data.csv')
Rows: 3 Columns: 2                                                      
── Column specification ────────────────────────────────────────────────
Delimiter: ","
chr (1): project
dbl (1): idUse `spec()` to retrieve the full column specification for this data.Specify the column types or set `show_col_types = FALSE` to quiet this message.
> print(as.character(data$id))
[1] "13101201211316084" "13101200510130348" "15103200910645448"

As one may observe, the last digits of the output are different from the last digits of the original data.

A cautious coder will know how many digits the numeric variable requires and make a judgment to specify col_types when reading the file. But we are often not careful. And it can potentially cause some serious problems down the road.

Would it be possible to add a warning message during read_csv import?

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

1 participant