Parses file size strings containing KB, MB, or GB units and converts them to a numeric value in megabytes.

parse_file_size_mb(file_size, rounding = 5)

Arguments

file_size

Character vector of file size strings (e.g. "531 KB", "1.8 MB").

rounding

Integer giving the number of decimal places to round to. Default is 5.

Value

A numeric vector of file sizes in megabytes.

Examples

parse_file_size_mb("531 KB")
#> [1] 0.51855
parse_file_size_mb("1.8 MB")
#> [1] 1.8
parse_file_size_mb(c("90 KB", "2 MB", "1 GB"))
#> [1] 8.789e-02 2.000e+00 1.024e+03