My trail on L
in R is:
c<-1:10
c
# [1] 1 2 3 4 5 6 7 8 9 10
c[-1]
# [1] 2 3 4 5 6 7 8 9 10
c[-2]
# [1] 1 3 4 5 6 7 8 9 10
c[-1L]
# [1] 2 3 4 5 6 7 8 9 10
c[-2L]
# [1] 1 3 4 5 6 7 8 9 10
I tried using ?L
without success.
What indeed is x[<n>L]
? Any example for further usage of it?
This answer is a summary of the comments above. It is basically just pointers to various help texts, but as evident from OP's attempt with
?L
, it is not always easy to find the relevant help text. I was expecting to find something aboutL
in?as.integer
, but no. Hopefully this answer is more useful than a pile of comments.L
suffix to qualify any number with the intent of making it an explicit integer"From
?NumericConstants
: "[...] All other numeric constants start with a digit or period and are either a decimal or hexadecimal constant optionally followed byL
""An numeric constant immediately followed by
L
is regarded as an integer number when possible (and with a warning if it contains a ".").""You can combine the "
0x
" prefix with the "L
" suffix".L
(as in “long”) after a number to make R create it as an integer".L
, but always relevant in the floating point vs. integers context is FAQ7.31: "Why doesn’t R think these numbers are equal?".Threads with discussions about the efficiency of
L
:Threads on R-help where others have struggled to find documentation about
L
, with a possible explanation of why the letterL
, and whyL
vsas.integer
in terms of efficiency.Difference between 10 and 10L
First William Dunlap:
Then Brian Ripley:
The L Word
Discussion about the efficiency in different situations, with some benchmarkings.
R history: Why 'L; in suffix character ‘L’ for integer constants?
More discussions here.