R/formatters.r
byte_format.Rd
Bytes formatter: convert to byte measurement and display symbol.
byte_format(symbol = "auto", units = "binary", only_highest = TRUE) Kb(x) Mb(x) Gb(x) bytes(x, symbol = "auto", units = c("binary", "si"), only_highest = FALSE)
symbol | byte symbol to use. If " |
---|---|
units | which unit base to use, " |
only_highest | Whether to use the unit of the highest number or each number uses its own unit. |
x | a numeric vector to format |
a function with three parameters, x
, a numeric vector that
returns a character vector, symbol
a single or a vector of byte
symbol(s) (e.g. "Kb
") desired and the measurement units
(traditional binary
or si
for ISI metric units).
Units of Information (Wikipedia) : http://en.wikipedia.org/wiki/Units_of_information
byte_format()(sample(3000000000, 10))#> [1] "0 Gb" "2 Gb" "0 Gb" "1 Gb" "2 Gb" "2 Gb" "0 Gb" "1 Gb" "1 Gb" "1 Gb"bytes(sample(3000000000, 10))#> [1] "829 Mb" "2 Gb" "3 Gb" "147 Mb" "2 Gb" "89 Mb" "861 Mb" "1 Gb" #> [9] "2 Gb" "516 Mb"Kb(sample(3000000000, 10))#> [1] "1,992,665 Kb" "1,879,920 Kb" "281,321 Kb" "2,254,907 Kb" "2,843,323 Kb" #> [6] "1,351,132 Kb" "511,746 Kb" "1,446,202 Kb" "598,179 Kb" "191,063 Kb"Mb(sample(3000000000, 10))#> [1] "2,361 Mb" "1,631 Mb" "1,706 Mb" "2,712 Mb" "1,558 Mb" "1,278 Mb" #> [7] "80 Mb" "1,116 Mb" "1,078 Mb" "2,452 Mb"Gb(sample(3000000000, 10))#> [1] "2 Gb" "1 Gb" "1 Gb" "1 Gb" "2 Gb" "3 Gb" "1 Gb" "2 Gb" "2 Gb" "0 Gb"