[R] how to judge a virable is a integer?

PO SU rhelpmaillist at 163.com
Sat Oct 18 13:21:41 CEST 2014


But i use a<-10/b ,  b is some value ,may be  5, maybe 5.5 
not in the form  xxL ,so how can i do in the situation to judge a ?






--

PO SU
mail: desolator88 at 163.com 
Majored in Statistics from SJTU



At 2014-10-18 18:58:48, "Berend Hasselman" <bhh at xs4all.nl> wrote:
>
>On 18-10-2014, at 12:41, PO SU <rhelpmaillist at 163.com> wrote:
>
>> 
>> 
>> Dear usRers,
>>    I want to judge virable is or not a integer?
>>   e.g.  is.integer(1)  FALSE   because it is a numeric, but i want it's true.
>> as.integer may not be used. because i don't know a is 1 or 1.1.
>> 
>
>is.integer is surely what you need if you wish to test if a variable is integer.
>See this
>
># a <- 1
># b <- 1L
>
># is.integer(a)
>[1] FALSE
>
># is.integer(b)
>[1] TRUE
>
>See the help for is.integer to see how you can test for a wholenumber, which might be what you want.
>
>Berend
>


More information about the R-help mailing list