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

Create a currency class to help improve formatting for currency data columns #427

Closed
joranE opened this issue Jun 27, 2018 · 5 comments
Closed

Comments

@joranE
Copy link

joranE commented Jun 27, 2018

The tibble formatting via pillar has some unfortunate side-effects if your numeric columns represent money:

money <- tibble(fund_balance = c(48379.49,98126352.56,983.14))
> money
# A tibble: 3 x 1
  fund_balance
         <dbl>
1       48379.
2    98126353.
3         983.

It's often nice to see the full amount to verify things are correct (to the penny!).

Similarly, rounding with currency data isn't helpful:

money2 <- tibble(fund_balance = c(79.49,52.56,83.14))
> money2
# A tibble: 3 x 1
  fund_balance
         <dbl>
1         79.5
2         52.6
3         83.1

It would be nice to be able to turn off some of these default formatting features specifically for columns that hold currency data.

@hadley
Copy link
Member

hadley commented Jun 27, 2018

Probably called decor_cur() with decimal places (default to 2) and currency label (optional, to appear in col type)

@krlmlr
Copy link
Member

krlmlr commented Mar 11, 2020

The {fmbasics} package looks very promising, needs a bit more work.

Relevant SO question: https://stackoverflow.com/q/14028995/946850.

@krlmlr krlmlr removed the vctrs ↗️ Requires vctrs package label Mar 11, 2020
@hadley
Copy link
Member

hadley commented Jun 5, 2020

I now think this is out of scope for tibble. We're likely to create a collection of helpers for various column types, but it's unlikely to be in tibble.

@Sibojang9
Copy link

This side-effect of tibble is quite surprising and counterintuitive. Hopefully, it could be fixed soon.

@github-actions
Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants