[R] Why are integers coded as e.g. 2L in R functions?

2014-05-15 Thread Alexander Engelhardt
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 __

Re: [R] Why are integers coded as e.g. 2L in R functions?

2014-05-15 Thread Rui Barradas
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)

Re: [R] Why are integers coded as e.g. 2L in R functions?

2014-05-15 Thread arun
Hi Alex, May be this link helps: http://stackoverflow.com/questions/7014387/whats-the-difference-between-1l-and-1 A.K. On Thursday, May 15, 2014 6:55 AM, Alexander Engelhardt a...@chaotic-neutral.de wrote: Hello R-help, I keep noticing R functions that don't compare integers like   if(x

Re: [R] Why are integers coded as e.g. 2L in R functions?

2014-05-15 Thread Pascal Oettli
Hello, Probably you will get more complete answer, but you can compare class(1) with class(1L). Regards, Pascal On Thu, May 15, 2014 at 7:54 PM, Alexander Engelhardt a...@chaotic-neutral.de wrote: Hello R-help, I keep noticing R functions that don't compare integers like if(x == 2) but

Re: [R] Why are integers coded as e.g. 2L in R functions?

2014-05-15 Thread Prof Brian Ripley
On 15/05/2014 11:54, Alexander Engelhardt wrote: 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? 2L is an integer. both in the

Re: [R] Why are integers coded as e.g. 2L in R functions?

2014-05-15 Thread Alexander Engelhardt
So in essence, it always provides the same output, but saves space and speed. Thanks everyone! - Alex On 05/15/2014 01:06 PM, Prof Brian Ripley wrote: On 15/05/2014 11:54, Alexander Engelhardt wrote: Hello R-help, I keep noticing R functions that don't compare integers like if(x == 2)