Converting to US customary units

Conversions between SI (International System) units (i.e. meters, grams, liters) and US customary units (i.e. feet, pounds, gallons) are not included as functions in this package. This is a deliberate pedagogical choice. The data is designed to be universally inclusive with SI units used by the majority of the world. Users who work with US customary units should convert them on their own.

This guide provides examples for making these different conversions, since not all of the variables involve straightforward multiplication.

Distance (meters ↔︎ feet)

Conversion factors

  • 1 foot = 0.3048 meters
  • 1 meter = 3.28084 feet

Derivation

A foot is officially defined as 0.3048 meters, so 1 meter = \(\frac{1}{0.3048}\) = 3.28084 feet.

Example

qatarcars |>
  mutate(
    length_ft = length / 0.3048,
    width_ft = width / 0.3048,
    height_ft = height / 0.3048
  ) |>
  select(make, model, length, length_ft, width, width_ft, height, height_ft)
#> # A tibble: 105 × 8
#>    make     model          length length_ft width width_ft height height_ft
#>    <fct>    <fct>           <dbl>     <dbl> <dbl>    <dbl>  <dbl>     <dbl>
#>  1 BMW      3 Series Sedan   4.71      15.5  1.83     5.99   1.44      4.72
#>  2 BMW      X1               4.50      14.8  1.84     6.05   1.64      5.39
#>  3 Audi     RS Q8            5.01      16.4  1.69     5.56   2.00      6.56
#>  4 Audi     RS3              4.54      14.9  1.85     6.07   1.41      4.63
#>  5 Audi     A3               4.46      14.6  1.96     6.43   1.42      4.65
#>  6 Mercedes Maybach          5.47      17.9  1.92     6.30   1.51      4.95
#>  7 Mercedes G-Wagon          4.61      15.1  1.98     6.51   1.97      6.46
#>  8 Mercedes EQS              5.22      17.1  1.93     6.32   1.51      4.96
#>  9 Mercedes GLA              4.41      14.5  1.83     6.02   1.61      5.29
#> 10 Mercedes GLB 200          4.63      15.2  4.63    15.2    1.66      5.44
#> # ℹ 95 more rows

Mass (kilograms ↔︎ pounds)

Conversion factors

  • 1 pound = 0.45359237 kilograms
  • 1 kilogram = 2.204623 pounds

Derivation

A pound is officially defined as 0.45359237 kilograms, so 1 kilogram = \(\frac{1}{0.45359237}\) = 2.204623 pounds.

Example

qatarcars |>
  mutate(mass_lbs = mass / 0.45359237) |>
  select(make, model, mass, mass_lbs)
#> # A tibble: 105 × 4
#>    make     model           mass mass_lbs
#>    <fct>    <fct>          <dbl>    <dbl>
#>  1 BMW      3 Series Sedan  1653    3644.
#>  2 BMW      X1              1701    3750.
#>  3 Audi     RS Q8           2490    5490.
#>  4 Audi     RS3             1565    3450.
#>  5 Audi     A3              1325    2921.
#>  6 Mercedes Maybach         2376    5238.
#>  7 Mercedes G-Wagon         2588    5706.
#>  8 Mercedes EQS             2495    5501.
#>  9 Mercedes GLA             1565    3450.
#> 10 Mercedes GLB 200         1656    3651.
#> # ℹ 95 more rows

Volume (liters ↔︎ cubic feet)

Conversion factors

  • 1 liter = 0.03531467 cubic feet
  • 1 cubic foot = 28.31684 liters

Derivation

1 liter = 0.001 cubic meters, so 1 liter = \(0.001 \times \left(\frac{1}{0.3048}\right)^3\) = 0.03531467 cubic feet. In reverse, 1 cubic foot = \(\frac{1}{0.03531467}\) = 28.31684 liters.

Example

qatarcars |>
  mutate(trunk_cuft = trunk * 0.001 * (1 / 0.3048)^3) |>
  select(make, model, trunk, trunk_cuft)
#> # A tibble: 105 × 4
#>    make     model          trunk trunk_cuft
#>    <fct>    <fct>          <dbl>      <dbl>
#>  1 BMW      3 Series Sedan    59       2.08
#>  2 BMW      X1               505      17.8 
#>  3 Audi     RS Q8            605      21.4 
#>  4 Audi     RS3              321      11.3 
#>  5 Audi     A3               425      15.0 
#>  6 Mercedes Maybach          500      17.7 
#>  7 Mercedes G-Wagon          480      17.0 
#>  8 Mercedes EQS              610      21.5 
#>  9 Mercedes GLA              435      15.4 
#> 10 Mercedes GLB 200          565      20.0 
#> # ℹ 95 more rows

Fuel economy (L/100km ↔︎ MPG)

Conversion factors

  • 1 L/100km ≈ 235.215 / MPG
  • 1 MPG ≈ 235.215 / L/100km
Note

These two units are inverted and can be counterintuitive! Higher MPG = lower L/100km.

In SI units, low economy values are good; in US customary units, high economy values are good. For instance, a car with 8 L/100km (≈29 MPG) is more efficient than one with 12 L/100km (≈20 MPG).

Derivation

A US gallon is officially defined as 3.785411784 liters, and 1 mile = \(\frac{0.3048 \times 5280}{1000}\) = 1.609344 kilometers.

\[ \begin{aligned} \text{L/100km} &\rightarrow \text{MPG} \\ &= \frac{100 \text{ km}}{\text{L/100km}} \times \frac{1 \text{ mile}}{1.609 \text{ km}} \times \frac{3.785 \text{ L}}{1 \text{ gallon}}\\ &= \frac{100 \times 3.785}{1.609 \times \text{L/100km}} \times \frac{\text{ miles}}{\text{ gallon}} \\ &\approx \frac{235.215}{\text{L/100km}} \text{ MPG} \end{aligned} \]

Example

economy_conversion_factor <- 100 *
  3.785411784 / # liters in a gallon
  (0.3048 * 5280 / 1000) # kilometers in a mile
economy_conversion_factor
#> [1] 235.2146

qatarcars |>
  mutate(economy_mpg = economy_conversion_factor / economy) |>
  select(make, model, economy, economy_mpg)
#> # A tibble: 105 × 4
#>    make     model          economy economy_mpg
#>    <fct>    <fct>            <dbl>       <dbl>
#>  1 BMW      3 Series Sedan     7.6        30.9
#>  2 BMW      X1                 6.6        35.6
#>  3 Audi     RS Q8             12.1        19.4
#>  4 Audi     RS3                8.7        27.0
#>  5 Audi     A3                 6.5        36.2
#>  6 Mercedes Maybach           13.3        17.7
#>  7 Mercedes G-Wagon           13.1        18.0
#>  8 Mercedes EQS               NA          NA  
#>  9 Mercedes GLA                5.6        42.0
#> 10 Mercedes GLB 200            7.5        31.4
#> # ℹ 95 more rows

Performance (0–100 km/h ↔︎ 0–60 mph)

Conversion factors

  • 0–60 mph (s) ≈ 0–100 km/h (s) × 0.9656064
  • 0–100 km/h (s) ≈ 0–60 mph (s) / 0.9656064
Note

This conversion is only approximate because 100 km/h corresponds to about 62 mph, not exactly 60 mph, and cars may not accelerate at a constant rate. The estimate assumes constant acceleration (time proportional to target speed). Since 60 mph is reached before 100 km/h, the actual 0–60 time would be slightly faster than the scaled estimate.

Derivation

60 mph = \(\frac{0.3048 \times 5280 \times 60}{1000}\) = 96.56064 km/h, so 60 mph is ≈96.56% of 100 km/h. Assuming constant acceleration, time scales proportionally to target speed, giving the conversion factor of 0.9656064.

Example

performance_conversion_factor <- 0.3048 * 5280 * 60 / 1000 / 100

qatarcars |>
  mutate(performance_mph = performance * performance_conversion_factor) |>
  select(make, model, performance, performance_mph)
#> # A tibble: 105 × 4
#>    make     model          performance performance_mph
#>    <fct>    <fct>                <dbl>           <dbl>
#>  1 BMW      3 Series Sedan         4.3            4.15
#>  2 BMW      X1                     5.4            5.21
#>  3 Audi     RS Q8                  3.6            3.48
#>  4 Audi     RS3                    3.8            3.67
#>  5 Audi     A3                     6.7            6.47
#>  6 Mercedes Maybach                4.1            3.96
#>  7 Mercedes G-Wagon                4.3            4.15
#>  8 Mercedes EQS                    5.6            5.41
#>  9 Mercedes GLA                    6.8            6.57
#> 10 Mercedes GLB 200                9              8.69
#> # ℹ 95 more rows

Automatic conversion with {units}

Alternatively, you can use the {units} package to make these conversions:

library(units)

qatarcars |>
  mutate(
    length_ft = set_units(length, "m") |> set_units("ft"),
    mass_lbs = set_units(mass, "kg") |> set_units("lb"),
    trunk_cuft = set_units(trunk, "L") |> set_units("ft^3"),
    economy_mpg = set_units(1 / (economy / 100), "km/L") |> set_units("mi/gallon")
  ) |>
  select(make, model, length_ft, mass_lbs, trunk_cuft, economy_mpg)
#> # A tibble: 105 × 6
#>    make     model          length_ft mass_lbs trunk_cuft economy_mpg
#>    <fct>    <fct>               [ft]     [lb]     [ft^3] [mi/gallon]
#>  1 BMW      3 Series Sedan      15.5    3644.       2.08        30.9
#>  2 BMW      X1                  14.8    3750.      17.8         35.6
#>  3 Audi     RS Q8               16.4    5490.      21.4         19.4
#>  4 Audi     RS3                 14.9    3450.      11.3         27.0
#>  5 Audi     A3                  14.6    2921.      15.0         36.2
#>  6 Mercedes Maybach             17.9    5238.      17.7         17.7
#>  7 Mercedes G-Wagon             15.1    5706.      17.0         18.0
#>  8 Mercedes EQS                 17.1    5501.      21.5         NA  
#>  9 Mercedes GLA                 14.5    3450.      15.4         42.0
#> 10 Mercedes GLB 200             15.2    3651.      20.0         31.4
#> # ℹ 95 more rows
Tip

{units} stores unit-specific metadata in the converted columns. Use drop_units() to convert these columns back to numeric values:

qatarcars |>
  mutate(
    length_ft = set_units(length, "m") |> set_units("ft") |> drop_units()
  )