[Rd] Historical NA question
Hervé Pagès
hpages at fhcrc.org
Tue May 6 01:05:40 CEST 2014
On 05/04/2014 06:35 PM, Michael Friendly wrote:
> On 03/05/2014 12:39 PM, Hadley Wickham wrote:
>> Can anyone tell me what the significance of 1954 is in R's NA?
>>
>
> Just ask R:
>
> > 2*(1-pnorm(1954))
> [1] 0
> > 2*(1-pnorm(1954)) %in% NA
> [1] 0
Not sure that would make the "joke" better, but you need parentheses
around the product because it seems %in% has precedence over * (the
fact that you got a number instead of a logical gives you a hint):
> (2*(1-pnorm(1954))) %in% NA
[1] FALSE
BTW, that %in% has precedence over arithmetic operations is surprising,
error-prone, and doesn't cover any reasonable use case (who needs to
multiply the logical vector returned by %in% by some value?) but that's
another story:
> 3 + 2 %in% 1:6
[1] 4
> 3 - 2 %in% 1:6
[1] 2
> 3 * 2 %in% 1:6
[1] 3
> 3 / 2 %in% 1:6
[1] 3
Weird!
H.
> >
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
--
Hervé Pagès
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024
E-mail: hpages at fhcrc.org
Phone: (206) 667-5791
Fax: (206) 667-1319
More information about the R-devel
mailing list