[R] Why is.integer() doesn't work with single values?
Ott Toomet
siim at obs.ee
Wed May 29 16:02:30 CEST 2002
Hi,
On Wed, 29 May 2002, Sven Garbade wrote:
Hi all,

I don't understand the behavior of is.integer():

> x < integer()
> is.integer(x)
[1] TRUE
> x < 10
> is.integer(x)
[1] FALSE
This is OK  x is now 10 (defaults to float), not any more integer(). Note
that assignment deleted the previous definition.
> x < 1:10
> is.integer(x)
[1] TRUE
1:10 defaults to an integer vector, so your new vector is (a vector of)
integer(s).
Why is.interger() returns FALSE if x has only one element? And how can
someone check if x is an integer but contains only one value? (R 1.5.0
on Linux i386)
length(x) gives the number of values.
is.integer() gives the type of argument (the way the argument is presented
in memory). E.g:
> x < 10
> is.integer(x)
[1] FALSE
> x == as.integer(x)
# use rather abs(x  as.integer(x)) < sqrt(Machine()$double.eps)
# or something similar.
[1] TRUE
> length(x)
[1] 1
Perhaps it helps.
Ott
.......................................
rhelp mailing list  Read http://www.ci.tuwien.ac.at/~hornik/R/RFAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: rhelprequest at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the Rhelp
mailing list