From hpages at fhcrc.org  Tue May  6 01:05:40 2014
From: hpages at fhcrc.org (=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=)
Date: Mon, 05 May 2014 16:05:40 -0700
Subject: [Rd] Historical NA question
In-Reply-To: <5366EAC6.9030109@yorku.ca>
References: <CABdHhvFt2n6=ORLBSTYxkA_G+t_d_H=0B1+vhhM_ZFL_Z-RT3g@mail.gmail.com>
	<5366EAC6.9030109@yorku.ca>
Message-ID: <53681944.9020606@fhcrc.org>

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



[Rd] Historical NA question
=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=