Last data update: 2014.03.03

R: Format a number of bytes into a human readable string.
formatBytesR Documentation

Format a number of bytes into a human readable string.

Description

Formats a number of bytes into a human readable string.

When invoked as formatBytes, SI sizes are used. You may specify IEC sizes by using formatIECBytes.

Usage

  formatBytes(b, fmt="%.2f")
  formatSIBytes(b, fmt="%.2f")
  formatIECBytes(b, fmt="%.2f")

Arguments

b

Number of bytes

fmt

String format for the numeric part of the bytes

Examples

  # returns "934.82MB"
  formatBytes(934818582)

  # returns "891.51MiB"
  formatIECBytes(934818582)

  # returns c("8.43KB", "3.52KB", "624.62KB", "46", "7.36KB")
  formatBytes(c(8429, 3525, 624624, 46, 7357))

Results