I expect there is already an answer for this on stackoverflow, and I simply failed to find it.

**Desired outcome:** Quickly convert the file size element in a `file.info()` call from bytes to KB, MB, etc. I'm fine if the output is either i) a character string with the desired size type, e.g., `"96 bytes"` or ii) simply a numeric conversion, e.g., from `60963` bytes to `60.963` KB (per [Google](https://www.google.com/search?q=60963+bytes+in+kilobytes&oq=60963+bytes+in+kilobytes&aqs=chrome..69i57.4026j0j1&sourceid=chrome&es_sm=93&ie=UTF-8)).

**Repro steps:**

1. Create a folder to store the file:

```
dir.create("census-app/data")

```
2. Download the file (~60KB):

```
download.file("http://shiny.rstudio.com/tutorial/lesson5/census-app/data/counties.rds",
"census-app/data/counties.rds")

```
3. Use `file.info()$size` to return the file size in bytes:

```
file.info("census-app//data//counties.rds")$size
[1] 60963

```

From there, I'm stuck. I realize I can do some complicated/manual parsing and calculation to make the conversion (see [Converting kilobytes, megabytes etc. to bytes in R](https://stackoverflow.com/questions/10910688/converting-kilobytes-megabytes-etc-to-bytes-in-r)).

However, I'm hoping I can simply use a base function or something similar:

```
    format(file.info("census-app//data//counties.rds")$size, units = "KB")
    [1] "60963"
    # Attempt to return file size in KB simply returns the size in bytes
    # NOTE: format(x, units = "KB") works fine when I
    # pass it object.size() for an object loaded in R

```