Re: [Rd] Historical NA question
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@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: hpa...@fhcrc.org Phone: (206) 667-5791 Fax:(206) 667-1319 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Historical NA question
On 06 May 2014, at 01:05 , Hervé Pagès wrote: > > 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: The point here is that the %foo% operators all have the _same_ precedence. In principle, they can be user-coded, and there is no way to express what precedence is desirable. It may turn out slightly weird for %in%, but think of what would happen if %*% had lower precedence than addition. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel