[R] A question about is.interger function

Michael H. Prager Mike.Prager at noaa.gov
Wed Apr 26 18:57:56 CEST 2006


Not to belabor the point, but if you really need to distinguish integers 
from other numerical constants, you could try something like this:

 > x <- as.integer(5)
 > typeof(x)
[1] "integer"
 > is.integer(x)
[1] TRUE
 >


on 4/26/2006 1:20 AM Leon said the following:
> Hi, All
> I am using is.integer function to examine whether an object is an integer or not, but I get such results,
>
>   
>> x<-3
>> is.integer(x)
>>     
> [1] FALSE
>
>   
>> x<-3:4
>> x
>>     
> [1] 3 4
>   
>> is.integer(x)
>>     
> [1] TRUE
>
> Seems that the is.integer cannot handle scalers, 
>
>   
>> is.integer(5)
>>     
> [1] FALSE
>
>   
>> is.integer(5:6)
>>     
> [1] TRUE
>
> Is this a bug in R or I made some mistakes? I am using R 2.2.1 under Windows XP
>
> Thanks a lot!
>
> Leon
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>   

-- 
Michael Prager, Ph.D.
Southeast Fisheries Science Center
NOAA Center for Coastal Fisheries and Habitat Research
Beaufort, North Carolina  28516
** Opinions expressed are personal, not official.  No
** official endorsement of any product is made or implied.




More information about the R-help mailing list