简体   繁体   中英

How do I interpret the units from object.size?

The documentation of object.size suggests that it can accept either "MB" or "Mb" as arguments to format . I understand that "B" is the abbreviation for byte and "b" for bit. However, when I call the format function with these two inputs, I get the same result. And this result has units of "b".

Is it respecting the distinction between bits and bytes? Or should I interpret all results as bytes despite the lower case "b"?

x <- runif(1e6)
format(object.size(x), "Mb")
#> [1] "7.6 Mb"
format(object.size(x), "MB")
#> [1] "7.6 Mb"

Created on 2022-09-12 by the reprex package (v2.0.1)

If you check the formatting part in the documentation you'll see that the default formatting is done in bytes.

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.

Also if you try:

> print(object.size(x))
8000048 bytes

where this equals roughly to 7.6 MB.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM