formatBytes: 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.82 MB"
  formatBytes(934818582)

  # returns "891.51 MiB"
  formatIECBytes(934818582)

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

dustin/humanFormat documentation built on Aug. 10, 2022, 1:57 a.m.