object_size works on an object and provides the size of the object using utils::object.size. as.object_size converts a numeric value to the units indicated in the unit argument.

object_size(x, unit = "MB", standard = "SI")

as.object_size(x, unit = "MB", standard = "SI")

Arguments

x

an R object.

standard

the byte-size unit standard to be used. A character string, possibly abbreviated from "legacy", "IEC", "SI" and "auto". See ‘Formatting and printing object sizes’ for details.

Value

A scalar character vector of the input object's size in the units requested

Examples

var <- 1e10
object_size(var, unit = "KB")
#> [1] "0.1 kB"

as.object_size(2500000)
#> [1] "2.5 MB"