[R] Why is.integer() doesn't work with single values?
siim at obs.ee
Wed May 29 16:02:30 CEST 2002
On Wed, 29 May 2002, Sven Garbade wrote:
|I don't understand the behavior of is.integer():
|> x <- integer()
|> x <- 10
This is OK -- x is now 10 (defaults to float), not any more integer(). Note
that assignment deleted the previous definition.
|> x <- 1:10
1:10 defaults to an integer vector, so your new vector is (a vector of)
|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
> x == as.integer(x)
# use rather abs(x - as.integer(x)) < sqrt(Machine()$double.eps)
# or something similar.
Perhaps it helps.
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help