R/formatter.r
number_bytes_format.Rd
Bytes formatter: convert to byte measurement and display symbol.
number_bytes_format(symbol = "auto", units = "binary", ...) number_bytes(x, symbol = "auto", units = c("binary", "si"), ...)
symbol | byte symbol to use. If "auto" the symbol used will be
determined by the maximum value of |
---|---|
units | which unit base to use, "binary" (1024 base) or "si" (1000 base) for ISI units. |
... | other arguments passed to |
x | a numeric vector to format |
a function with three parameters, x``, a numeric vector that returns a character vector,
symbolthe byte symbol (e.g. "Kb") desired and the measurement
units(traditional
binaryor
si` for ISI metric units).
Units of Information (Wikipedia) : http://en.wikipedia.org/wiki/Units_of_information
number_bytes_format()(sample(3000000000, 10))#> [1] "3 Gb" "2 Gb" "1 Gb" "3 Gb" "3 Gb" "0 Gb" "0 Gb" "1 Gb" "2 Gb" "1 Gb"number_bytes(sample(3000000000, 10))#> [1] "1 Gb" "1 Gb" "1 Gb" "3 Gb" "2 Gb" "2 Gb" "3 Gb" "1 Gb" "2 Gb" "1 Gb"number_bytes(sample(3000000000, 10), accuracy = .1)#> [1] "2.6 Gb" "2.1 Gb" "1.1 Gb" "2.1 Gb" "0.2 Gb" "0.2 Gb" "0.3 Gb" "0.7 Gb" #> [9] "0.5 Gb" "0.9 Gb"