##> # A tibble: 3 × 3
##> name `size in m` `speed in m/s`
##> <chr> <chr> <chr>
##> 1 land snail " 75 m" " 1 m"
##> 2 photon " NA " "299.79 M"
##> 3 African plate "10.55 M" " 681 p"
Time intervals
pretty_ms formats a time interval given in milliseconds. pretty_sec
does the same for seconds, and pretty_dt for difftime objects. The
optional compact argument turns on a compact, approximate format.
vague_dt and time_ago formats time intervals using a vague format,
omitting smaller units. They both have three formats: default, short
and terse. vague_dt takes a difftime object, and time_ago works
relatively to the specified date.
vague_dt(format = "short", as.difftime(30, units = "secs"))
##> [1] "<1 min"
vague_dt(format = "short", as.difftime(14, units = "mins"))
##> [1] "14 min"
vague_dt(format = "short", as.difftime(5, units = "hours"))
##> [1] "5 hours"
vague_dt(format = "short", as.difftime(25, units = "hours"))
##> [1] "1 day"
vague_dt(format = "short", as.difftime(5, units = "days"))
##> [1] "5 day"
now <- Sys.time()
time_ago(now)
##> [1] "moments ago"
time_ago(now - as.difftime(30, units = "secs"))
##> [1] "less than a minute ago"
time_ago(now - as.difftime(14, units = "mins"))
##> [1] "14 minutes ago"
time_ago(now - as.difftime(5, units = "hours"))
##> [1] "5 hours ago"
time_ago(now - as.difftime(25, units = "hours"))
##> [1] "a day ago"
Rounding
pretty_round() and pretty_signif() preserve trailing zeros.
pretty_round(1, digits=6)
##> [1] "1.000000"
pretty_signif(c(99, 0.9999), digits=3)
##> [1] "99.0" "1.00"
p-values
pretty_p_value() rounds small p-values to indicate less than
significance level for small values.
pretty_p_value(c(0.05, 0.0000001, NA))
##> [1] "0.0500" "<0.0001" NA
Colors
pretty_color converts colors from other representations to
human-readable names.
prettyunits
The
prettyunitspackage formats quantities in human readable form.Installation
You can install the package from CRAN:
If you need the development version, install it from GitHub:
Bytes
pretty_bytesformats number of bytes in a human readable way:Here is a simple function that emulates the Unix
lscommand, with nicely formatted file sizes:Quantities
pretty_numformats number related to linear quantities in a human readable way:Be aware that the result is wrong in case of surface or volumes, and for any non-linear quantity.
Here is a simple example of how to prettify a entire tibble
Time intervals
pretty_msformats a time interval given in milliseconds.pretty_secdoes the same for seconds, andpretty_dtfordifftimeobjects. The optionalcompactargument turns on a compact, approximate format.Vague time intervals
vague_dtandtime_agoformats time intervals using a vague format, omitting smaller units. They both have three formats:default,shortandterse.vague_dttakes adifftimeobject, andtime_agoworks relatively to the specified date.Rounding
pretty_round()andpretty_signif()preserve trailing zeros.p-values
pretty_p_value()rounds small p-values to indicate less than significance level for small values.Colors
pretty_colorconverts colors from other representations to human-readable names.