Displaying 1 result from an estimated 1 matches for "1inches".
Did you mean:
inches
2020 Apr 29
1
grid 4.0 generates wrong results when adding two complex units by sum()
...In the following example, `u1 + u2` gives the correct result, but `sum(u1, u2)` also `sum(unit.c(u1, u2))` give the wrong results.
```
library(grid)
u1 = 0.4*sum(unit(1, "inch"), unit(1, "mm"))
u2 = 0.1*sum(unit(1, "inch"), unit(1, "mm"))
u1
# [1] 0.4*sum(1inches, 1mm)
u2
# [1] 0.1*sum(1inches, 1mm)
# this is correct
u1 + u2
# [1] 0.5*sum(1inches, 1mm)
# but this is wrong, it should return `sum(0.4inches, 0.4mm, 0.1inches, 0.1mm)`, right?
sum(u1, u2)
# [1] sum(0.4inches, 0.1mm, 1inches, 1mm)
sum(unit.c(u1, u2)) # this is also wrong
# [1] sum(0.4inches, 0....