r-quantities/units

Unit not preserved when computing standard deviation

Closed this issue · 2 comments

When reducing a vector with the sd function the unit is dropped. Is that the expected behavior?

library(units)
a <- rnorm(200, mean = 23, sd = 2.1)
b <- set_units(a, m^2)
mean(b) # 23.07854 [m^2]
sd(b) # [1] 2.199572
edzer commented

Yes, sd is a function, not a generic, so we can't provide a method for units objects.

Understood, thanks @edzer