[R] The L Word

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Feb 24 11:20:12 CET 2011


On Thu, 24 Feb 2011, Tal Galili wrote:

> Thank you all for the answers.
>
> So if I may extend on the question -
> When is it important to use 'Literal integer'?
> Under what situations could not using it cause problems?
> Is it a matter of efficiency or precision or both?

Efficiency: it avoids unnecessary type conversions.  For example

length(x) > 1

has to coerce the lhs to double.  We have converted the base code to 
use integer constants because such small efficiency gains can add up.

Integer vectors can be stored more compactly than doubles, but that is 
not going to help for length 1:

> object.size(1)
48 bytes
> object.size(1L)
48 bytes

(32-bit system).

>
> Thanks,
> Tal
>
>
>
>
> ----------------Contact
> Details:-------------------------------------------------------
> Contact me: Tal.Galili at gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
> ----------------------------------------------------------------------------------------------
>
>
>
>
> On Wed, Feb 23, 2011 at 6:15 PM, Tsjerk Wassenaar <tsjerkw at gmail.com> wrote:
>
>> Hi Gene,
>>
>> It means 'Literal integer'.
>> So 1L is a proper integer 1, and 0L is a proper integer 0.
>>
>> Hope it helps,
>>
>> Tsjerk
>>
>> On Wed, Feb 23, 2011 at 5:08 PM, Gene Leynes <gleynes+r at gmail.com> wrote:
>>> I've been wondering what L means in the R computing context, and was
>>> wondering if someone could point me to a reference where I could read
>> about
>>> it, or tell me what it's called so that I can search for it myself.  (L
>> by
>>> itself is a little too general for a search term).
>>>
>>> I encounter it in strange places, most recently in the "save"
>> documentation.
>>>
>>> save(..., list = character(0L),
>>>>      file = stop("'file' must be specified"),
>>>>      ascii = FALSE, version = NULL, envir = parent.frame(),
>>>>      compress = !ascii, compression_level,
>>>>      eval.promises = TRUE, precheck = TRUE)
>>>>
>>>
>>> I remember that you can also find it when you step inside an apply
>> function:
>>>
>>>> sapply(1:10, function(x)browser())
>>>> Called from: FUN(1:10[[1L]], ...)
>>>>
>>>
>>> I apologize for being vague, it's just something that I would like to
>>> understand about the R language (the R word).
>>>
>>> Thank you!
>>>
>>> Gene
>>>
>>>        [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> 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.
>>>
>>
>>
>>
>> --
>> Tsjerk A. Wassenaar, Ph.D.
>>
>> post-doctoral researcher
>> Molecular Dynamics Group
>> * Groningen Institute for Biomolecular Research and Biotechnology
>> * Zernike Institute for Advanced Materials
>> University of Groningen
>> The Netherlands
>>
>> ______________________________________________
>> 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.
>>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list