[R] extra .
Steve Lianoglou
mailinglist.honeypot at gmail.com
Fri Aug 21 18:02:09 CEST 2009
Hi,
This is somehow unrelated, but your answer brings up a question that
I've been curious about:
On Aug 21, 2009, at 11:48 AM, William Dunlap wrote:
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org
>> [mailto:r-help-bounces at r-project.org] On Behalf Of kfcnhl
>> Sent: Thursday, August 20, 2009 7:34 PM
>> To: r-help at r-project.org
>> Subject: [R] extra .
>>
>>
>> sigma0 <- sqrt((6. * var(maxima))/pi)
>>
>> What does the '.' do here?
>
> In R it does nothing: both '6' and '6.' parse as "numerics"
> (in C, double precision numbers). In SV4 and S+ '6' parses
> as an integer (in C, a long) and '6.' parses as a numeric,
> so putting the decimal point after numerics makes the
> code a bit more portable, although there are not too many
> cases where the difference is significant. Calls to .C, etc.,
> and oveflowing arithmetic are the main problem points.
>
> In R and S+ '6L' represents an integer.
If this is true, I'm curious as to why when I'm poking through some
source code of different packages, I see that some people are careful
to explicitly include the L after integers?
I can't find a good example at the moment, but you can see one such
case in the source to the lm.fit function. The details aren't all that
important, but here's one of the lines:
r2 <- if (z$rank < p)
(z$rank + 1L):p
I mean, why not just (z$rank + 1):p ?
Just wondering if anybody has any insight into that. I've always been
curious and I seem to see it done in many different functions and
packages, so I feel like I'm missing something ...
Thanks,
-steve
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the R-help
mailing list