[Rd] can we override "if" in R?

Hadley Wickham h.wickham at gmail.com
Sun Mar 5 19:35:44 CET 2017


On Sun, Mar 5, 2017 at 8:13 PM, Gábor Csárdi <csardi.gabor at gmail.com> wrote:
> Because the S3 class system is very informal. E.g. if you happen to
> have an `if.whatever` function, that will be automatically a method of
> your generic.

For example:

x <- structure(1:10, class = "test")
t(x)
#>
#>  One Sample t-test
#>
#> data:  x
#> t = 5.7446, df = 9, p-value = 0.0002782
#> alternative hypothesis: true mean is not equal to 0
#> 95 percent confidence interval:
#>  3.334149 7.665851
#> sample estimates:
#> mean of x
#>       5.5


-- 
http://hadley.nz



More information about the R-devel mailing list