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

Leading zeroes #266

Closed
jennybc opened this issue Sep 21, 2015 · 5 comments
Closed

Leading zeroes #266

jennybc opened this issue Sep 21, 2015 · 5 comments

Comments

@jennybc
Copy link
Member

@jennybc jennybc commented Sep 21, 2015

I wonder if leading zeroes should cause a column to come in as character? I know I can force the variable to be character and will do so in my current example.

But I suspect that numbers with leading zeroes should be treated as character more often than not. Examples: social security numbers, zip codes, phone numbers with country exit codes, numbers written written for alphalexical sorting, and agent identifiers in the 00 Section of MI6.

@hadley
Copy link
Member

@hadley hadley commented Sep 21, 2015

Seems reasonable to me. Reprex:

collectorGuess("00001", default_locale())
@hadley
Copy link
Member

@hadley hadley commented Sep 21, 2015

Hmmm, this is easy enough to do for integers, but what's the rule for doubles? Should 001.1234 be parsed as a double? What about 0.1? Is the rule that if there's an initial zero, it must be followed by a period?

@jennybc
Copy link
Member Author

@jennybc jennybc commented Sep 22, 2015

I think if it just worked for integers that would still be really nice. All my real-life examples are unambiguously integer (last x digits of student IDs, player numbers such as 00 or 06, etc.).

@hadley
Copy link
Member

@hadley hadley commented Sep 22, 2015

You have to think about doubles because 00001 is both an integer and a double, so if I fix it so readr doesn't think it's an integer, it'll just get detected as a double, which isn't a big improvement.

@hadley
Copy link
Member

@hadley hadley commented Sep 22, 2015

This is what I have so far

collector_guess("0")
#> [1] "integer"
collector_guess("0.")
#> [1] "double"
collector_guess("0001")
#> [1] "character"
@hadley hadley closed this in ec04976 Sep 22, 2015
@lock lock bot locked and limited conversation to collaborators Sep 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants