Skip to content

Currency parser #444

@jimhester

Description

@jimhester

As mentioned in #308 (comment) we do not support negative currencies for parse number

parse_number("-$3")
#> Warning: 1 parsing failure.
#> row col expected actual
#>   1  -- a number     -$
#> [1] NA
#> attr(,"problems")
#> # A tibble: 1 x 4
#>     row   col expected actual
#>   <int> <int>    <chr>  <chr>
#> 1     1    NA a number     -$

# putting the - directly in front of the number works, but this does not seem to be the standard way to format currencies in the US
parse_number("$-3")
#> [1] -3

# Should we also support using parenthesis for this case?
parse_number("($3)")
#> Warning: 1 parsing failure.
#> row col expected actual
#>   1  -- a number     3)
#> [1] NA
#> attr(,"problems")
#> # A tibble: 1 x 4
#>     row   col expected actual
#>   <int> <int>    <chr>  <chr>
#> 1     1    NA a number     3)

Perhaps we should have a parse_currency() and col_currency() which would be locale aware to handle this and other cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions