| 1 |
# errors if unknown unit |
| 2 |
|
| 3 |
Code |
| 4 |
label_bytes("unit")(0) |
| 5 |
Condition |
| 6 |
Error: |
| 7 |
! `units` must be one of "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", "kiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", or "YiB", not "unit". |
| 8 |
|
| 9 |
# Byte formatter can take a symbol designator |
| 10 |
|
| 11 |
Code |
| 12 |
number_bytes(c(50, 400, 502, NA), symbol = "k") |
| 13 |
Condition |
| 14 |
Warning: |
| 15 |
`symbol` must be one of auto, B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, or YiB |
| 16 |
i The provided value ("k") will be changed to the default ("auto") |
| 17 |
Output |
| 18 |
[1] "50 B" "400 B" "502 B" NA |
| 19 |
|
| 20 |
--- |
| 21 |
|
| 22 |
Code |
| 23 |
number_bytes(1024^(1:2), "kB", units = "binary") |
| 24 |
Condition |
| 25 |
Warning: |
| 26 |
`symbol` must be one of auto, B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, or YiB |
| 27 |
i The provided value ("kB") will be changed to the default ("auto") |
| 28 |
Output |
| 29 |
[1] "1 KiB" "1 MiB" |
| 30 |
|
| 31 |
--- |
| 32 |
|
| 33 |
Code |
| 34 |
number_bytes(1024^(1:2), "KiB", units = "si") |
| 35 |
Condition |
| 36 |
Warning: |
| 37 |
`symbol` must be one of auto, B, kB, MB, GB, TB, PB, EB, ZB, or YB |
| 38 |
i The provided value ("KiB") will be changed to the default ("auto") |
| 39 |
Output |
| 40 |
[1] "1 kB" "1 MB" |
| 41 |
|
| 42 |
# Byte formatter throws informative error for wrong length symbol |
| 43 |
|
| 44 |
Code |
| 45 |
number_bytes(symbol = character()) |
| 46 |
Condition |
| 47 |
Error in `validate_byte_symbol()`: |
| 48 |
! `symbol` must have length 1, not length 0 |
| 49 |
|
| 50 |
--- |
| 51 |
|
| 52 |
Code |
| 53 |
number_bytes(symbol = c("kB", "MB")) |
| 54 |
Condition |
| 55 |
Error in `validate_byte_symbol()`: |
| 56 |
! `symbol` must have length 1, not length 2 |
| 57 |
|