r-quantities / units

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

Changing unit sign not working properly #224

Closed kendonB closed 4 years ago

kendonB commented 4 years ago
library(units)
#> udunits system database from /usr/share/xml/udunits
x = set_units(1:5, "m/s", mode = "standard")
# Sign change works but units printed should be -m/s
x = set_units(x, "-m/s")
x
#> Units: [m/s]
#> [1] -1 -2 -3 -4 -5
# This switches the sign back but shouldn't 
x = set_units(x, "-m/s")
x
#> Units: [m/s]
#> [1] 1 2 3 4 5

Created on 2020-02-21 by the reprex package (v0.3.0)

Enchufa2 commented 4 years ago

I don't agree in either case. First, you are introducing a minus sign, and this is propagated to the quantity. There is no such a thing as a negative unit. In the second case, it's the same.