I'm not sure whether making "var" a generic would not shift the problem
to the next function not being generic, you could experiment with that.
On 1/20/19 6:39 PM, Kenny Bell wrote:
> Hi all,
> I am running into problems using `summary.lm` as calling `var` on a `units`
> object does not retain the `units` attribute.
> The units package addresses this issue for `mean` by implementing
> function (x, ...)
> .as.units(NextMethod(), units(x))
> This is, however, not possible for `var` (as it's not a generic), which
> breaks `summary.lm`:
> #> udunits system database from C:/R/Library/3.5/units/share/udunits
> iris$Sepal.Length <- set_units(iris$Sepal.Length, "cm")
> summary(lm(Sepal.Length ~ Sepal.Width,
> data = iris))
> #> Error in Ops.units(mean(f)^2, var(f)): both operands of the expression
> should be "units" objects
> Created on 2019-01-21 by the [reprex package](https://reprex.tidyverse.org)
> Apologies if `stats` package emails shouldn't go here.
> [[alternative HTML version deleted]]
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel >