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

Reading a number with the incorrect decimal mark does not fail #1522

Open
zsigmas opened this issue Nov 22, 2023 · 0 comments
Open

Reading a number with the incorrect decimal mark does not fail #1522

zsigmas opened this issue Nov 22, 2023 · 0 comments

Comments

@zsigmas
Copy link

zsigmas commented Nov 22, 2023

When there is a mixture of numbers with points or commas for decimal markers, readr::read_delim (I assume this would also be the case for other reading functions) the result is unexpected. When 2.1 is parsed with a decimal marker set to "," I would expect an NA value or an error, but the number 21 or 2 is returned depending on the grouping_mark.

My intuition is that it all boils down to the readr::parse_number function.

readr::parse_number("2.1", locale = readr::locale(decimal_mark = ",", grouping_mark = "."))
# [1] 21
# Expected an NA or error, but not a number

readr::parse_number("2.1", locale = readr::locale(decimal_mark = ",", grouping_mark = ""))
# [1] 2
# Expected an NA or error, but not a number

Thanks a lot!

locale

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=en_US.UTF-8          
 [9] LC_ADDRESS=en_US.UTF-8        LC_TELEPHONE=en_US.UTF-8      LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

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