[R] Why are integers coded as e.g. "2L" in R functions?
Rui Barradas
ruipbarradas at sapo.pt
Thu May 15 13:03:29 CEST 2014
Hello,
2 is a double, 2L is an integer. Try
> class(2)
[1] "numeric"
> class(2L)
[1] "integer"
Hope this helps,
Rui Barradas
Em 15-05-2014 11:54, Alexander Engelhardt escreveu:
> Hello R-help,
>
> I keep noticing R functions that don't compare integers like
> if(x == 2)
> but instead
> if(x == 2L)
>
> Is this a long integer? Also, when do the two notations have a different
> effect on the code?
>
> Thanks in advance,
> Alex
>
> ______________________________________________
> 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