Skip to content

Leading zeroes #266

Description

@jennybc

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.

Activity

  1. hadley commented on Sep 21, 2015

    @hadley
    Member

    Seems reasonable to me. Reprex:

    collectorGuess("00001", default_locale())
  2. hadley commented on Sep 21, 2015

    @hadley
    Member

    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?

  3. jennybc commented on Sep 22, 2015

    @jennybc
    MemberAuthor

    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.).

  4. hadley commented on Sep 22, 2015

    @hadley
    Member

    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.

  5. hadley commented on Sep 22, 2015

    @hadley
    Member

    This is what I have so far

    collector_guess("0")
    #> [1] "integer"
    collector_guess("0.")
    #> [1] "double"
    collector_guess("0001")
    #> [1] "character"
  6. locked and limited conversation to collaborators on Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions