-
Notifications
You must be signed in to change notification settings - Fork 13
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
Percent class for working with percentages #127
Comments
This was agreed to take forward as a PR |
There are a few things I'm not sure about regarding the implementation from a user-perspective.
|
Have now opened a PR here #130 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Motivation
Working with percentages in R can be annoying to say the least and in day-to-day analyses I tend to find myself in this general workflow:
Having a percent class object could reduce this workflow by combining the two vectors into one, reducing the work needed to manage independent vectors.
Describe the solution you'd like
It would be nice to see a percent class that represents proportions without losing precision and simply prints them as
percentages.
This would help analysts across PHS spend less time thinking about how to format percentages.
Describe alternatives you've considered
I have made a small package that does this, see: github.com/NicChr/percent
I'm aware of
scales::percent()
but this returns a character vector whereasas_percent()
does no transformations at all, returning an object of class "percent", preserving the proportions vector and printing as a "percent" vector in tibbles.@Tina815 @Moohan Let me know if you think this would be a good fit for phsmethods and if so I'd be happy to assist in future implementations.
If this was deemed to be a good fit, I would be happy for the code to be copied over, reducing the need for another package dependency.
Below I've included some basic examples.
Basic usage
Created on 2024-03-07 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: