prettyunits
prettyunits copied to clipboard
Add {units} compatibility with majority-vote for best units
This is an opinionated PR to make pretty_num work with class("units") number. I'm not confortable with the package dependencies impact. I think it would be much cleaner to turn both impacted functions into S3 methods and split the "units::" part of this P.R. into a P.R. to the {units} team
Codecov Report
Merging #28 (0349006) into master (b1cdad8) will increase coverage by
5.24%. The diff coverage is79.03%.
@@ Coverage Diff @@
## master #28 +/- ##
==========================================
+ Coverage 65.26% 70.51% +5.24%
==========================================
Files 4 5 +1
Lines 95 156 +61
==========================================
+ Hits 62 110 +48
- Misses 33 46 +13
| Impacted Files | Coverage Δ | |
|---|---|---|
| R/numbers.R | 78.33% <78.33%> (ø) |
|
| R/sizes.R | 18.42% <100.00%> (+2.20%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update b1cdad8...0349006. Read the comment docs.
Thanks! I updated this, so it could be merged. However, it would be great to drop the hard dependency on units.
Maybe we can move it to Suggests?
Also, the current implementation fails, because it seems that we cannot compare 'units' objects and regular numbers any more:
library(units)
l_cm <- set_units(1337129, cm)
pretty_num(l_cm)
#> Error in Ops.units(amt, as.integer(amt)) :
#> both operands of the expression should be "units" objects
l_cm < 0
#> Error in Ops.units(l_cm, 0) :
#> both operands of the expression should be "units" objects
I'll have a look this week on it...