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"), ...)

Arguments

symbol

byte symbol to use. If "auto" the symbol used will be determined by the maximum value of x. Valid symbols are "b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", and "Yb", along with their upper case equivalents and "iB" equivalents.

units

which unit base to use, "binary" (1024 base) or "si" (1000 base) for ISI units.

...

other arguments passed to number()

x

a numeric vector to format

Value

a function with three parameters, x``, a numeric vector that returns a character vector,symbolthe byte symbol (e.g. "Kb") desired and the measurementunits(traditionalbinaryorsi` for ISI metric units).

References

Units of Information (Wikipedia) : http://en.wikipedia.org/wiki/Units_of_information

Examples

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"