-
Notifications
You must be signed in to change notification settings - Fork 78
Add subclasses #154
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
base: master
Are you sure you want to change the base?
Add subclasses #154
Conversation
|
I'll take a closer look at this soon. |
R/val_prefix.R
Outdated
| prefix <- function(x, prefix = "", sep = "", ..., na.text = NULL) { | ||
| formattable(x, ..., | ||
| formattable(x, | ||
| class = "formattable_prefix", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason prefix and suffix uses a class? These two functions are intended to tweak existing formats.
I inspect the class attribute like the following:
> str(suffix(prefix(currency(acct, symbol = "HK$"), "*"), "#"))
'formattable_accounting' num [1:3] *HK$10,000.00# *HK$500,000.00# *HK$-20,000.00#
- attr(*, "formattable")=List of 5
..$ formatter: chr "formatC"
..$ format :List of 3
.. ..$ format : chr "f"
.. ..$ big.mark: chr ","
.. ..$ digits : int 2
..$ preproc : NULL
..$ postproc :List of 3
.. ..$ :function (str, x)
.. ..$ :function (str, x)
.. ..$ :function (str, x)
..$ class : chr [1:4] "formattable_suffix" "formattable_accounting" "formattable" "numeric"However, the prefix class seems missing somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, this doesn't look right. Maybe prefix and suffix don't need their own class.
|
A bit off the topic. @krlmlr Please feel free to add yourself as a contributor to |
|
pillar 1.6.0 is on CRAN now. |
|
One thing to notice is that the class name is bit too long for printing: Do you think we should simplify or shorten the class name? |
|
We could also add |
A separate PR makes good sense. |
We want to know that a formattable is actually "accounting" or "currency" after we have constructed it. This helps implementing
pillar_shaft()methods for formattable.Are you on board with this? Are there reasons against? I ran a revdepcheck: https://github.com/renkun-ken/formattable/actions/runs/660611546. Two packages are now failing but it's unrelated to this PR because we no longer import htmltools and rmarkdown.
This is a big change I couldn't break into smaller pieces.