Closed vorpalvorpal closed 2 years ago
You missed the operator precedance of *
and %>%
, try
(area*rain) %>% set_units(l)
Sorry I don't understand. Why do I want to convert it to unitless (1) before converting to volume? Also, it doesn't work.
(area*rain) %>% set_units(1)
# Error: cannot convert ha*mm into 1
set_units(area*rain, 1)
# Error: cannot convert m2*mm into 1
I used l
for liter, not 1
.
@vorpalvorpal In other words, without parentheses, you think you are doing this
(area * rain) |> set_units("liter")
#> 1e+08 [L]
but instead you are doing this
area * (rain |> set_units("liter"))
#> Error: cannot convert mm into L
See https://stat.ethz.ch/R-manual/R-devel/library/base/html/Syntax.html
To calculate the number of L of rain falling on an area we calculate area*depth. This doesn't appear to work with units because m2 != m^2. Is there a correct way of doing this with out dropping units and then reapplying them?
Example: