r - Package for formatting numeric values in reproducible research -
is there standard way of converting numeric values character particular type of formatting applied.
i'm thinking of like:
formatr(32390,"dollars") # returns "$32,390" formatr(1.25,"percent") # returns "125%"
obviously, not hard write them myself, need kind of thing pretty constant in when preparing reports, , there must package out there already?
the scales
package provides few formatting functions,
> scales::percent(c(1.2, 0.13)) [1] "120%" "13%" > scales::dollar(c(1.2, 0.13)) [1] "$1.20" "$0.13" > scales::comma(c(1.2, 0.13)) [1] "1.20" "0.13" > scales::comma(scales::dollar(6000.88)) [1] "$6,000.88"
Comments
Post a Comment