[R] Where are usages like "== 2L" documented?

Bryan Hanson hanson at depauw.edu
Tue Nov 17 15:11:11 CET 2009


Patrick reminded me that it's also in The R Inferno, another document that I
need to read again.

So now, a more particular semi-question:

x <- 1L
y <- 1
z <- 1.0

class(x) # integer
class(y) # numeric
class(z) # numeric

x == 1
x == 1L
y == 1
z == 1 # all test TRUE

Just to clarify, I think the steps above prove it, but *in a test* like x ==
1 the test is for the contents, not the storage mode, not for a combination
of storage mode and contents.

So... The reason for defining the notion of "L" is smaller storage space,
and more generally, for use anytime one wants explictly an integer for
whatever reason?  Are there other reasons, for instance, ways it saves lines
of code?

Bryan
*************
Bryan Hanson
Acting Chair
Professor of Chemistry & Biochemistry
DePauw University, Greencastle IN USA



On 11/17/09 4:20 AM, "Patrick Burns" <pburns at pburns.seanet.com> wrote:

> 'The R Inferno' page 75.
> 
> 
> 
> Patrick Burns
> patrick at burns-stat.com
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of "The R Inferno" and "A Guide for the Unwilling S User")
> 
> Bryan Hanson wrote:
>> Gurus:
>> 
>> I keep seeing other people¹s code that contain ideas like
>> 
>> If (x == 2L)
>> X[-1L]
>> X - 1L
>> 
>> I have some idea of what¹s going on, but where is the use of concepts like
>> ³2L² documented?
>> 
>> Thanks, Bryan
>> *************
>> Bryan Hanson
>> Acting Chair
>> Professor of Chemistry & Biochemistry
>> DePauw University, Greencastle IN USA
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 




More information about the R-help mailing list