r-quantities / units

Measurement units for R
https://r-quantities.github.io/units
173 stars 27 forks source link

Incorrect square foot to acre conversion #317

Closed iembry closed 2 years ago

iembry commented 2 years ago

Hi, I'm using units version 0.8-0 and I have come across the following incorrect conversion:

ft2 <- set_units(43560, ft ^ 2)

acre <- ft2

units(acre) <- make_units(acre)

0.999996 [acre]

According to the UDUNITS-2 database, an acre is "unit of area in the US Customary System, used in land and sea floor measurement, equal to 43560 square feet".

Please correct the conversion error.

Thank you.

Irucka

edzer commented 2 years ago
> set_units(1, acre) |> set_units(foot^2)
43560.17 [foot^2]

The R units package uses the C udunits library, but doesn't define it. If you believe this is an error, you need to report it upstream.

edzer commented 2 years ago

For instance, the udunits2 command line tool gives

$ udunits2
You have: 1 acre
You want: foot^2
    1 acre = 43560.2 foot^2
    x/foot^2 = 43560.2*(x/acre)

(and seems to round to 6 digits)

Enchufa2 commented 2 years ago

@iembry The conversion is fine. You just didn't use the proper foot.

ft2 <- set_units(43560, US_survey_foot ^ 2)
acre <- ft2
units(acre) <- make_units(acre)
acre
#> 1 [acre]

set_units(as_units("US_survey_foot"), foot)
#> 1.000002 [foot]

¯_(ツ)_/¯

iembry commented 2 years ago

@ Enchufa2 Thank you for your suggestion! I'll use the proper foot unit.