From h.wickham at gmail.com  Sun Mar  5 19:35:44 2017
From: h.wickham at gmail.com (Hadley Wickham)
Date: Mon, 6 Mar 2017 07:35:44 +1300
Subject: [Rd] can we override "if" in R?
In-Reply-To: <CABtg=KmmtEm1m8t6-vngxYEgjLecsRdGHVS62YwCWT21VqXVqA@mail.gmail.com>
References: <CAFLer83hbY+3QEfoukAmt4Hy77P5=NyW3a+pyigV0CJVjzjYdA@mail.gmail.com>
	<CABtg=KkmsPVZc0Y-Rru5+DkzLHabrkVDOZWcip5jhYHD-D4HZg@mail.gmail.com>
	<CAFLer83OTdZQq+=Uj5g7fqmph8-FWwa7pFSMmz_dhcKhs8DuCA@mail.gmail.com>
	<CABtg=Kn83hAzBGyJkVrWciAYadJDsT2GmLPY4OF2_o30cxG1Ww@mail.gmail.com>
	<CAFLer83n1uv_14fLBYg78CkAKiEUsMjeSXObto7gSyS+0TTfpA@mail.gmail.com>
	<CABtg=KmmtEm1m8t6-vngxYEgjLecsRdGHVS62YwCWT21VqXVqA@mail.gmail.com>
Message-ID: <CABdHhvFNgF4mkt8pMx02N3cGig2dO2+O8H_R9Sfek+7Wu+yH-Q@mail.gmail.com>

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



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