Re: [R] Why is.integer() doesn't work with single values?

About this list Date view Thread view Subject view Author view Attachment view

From: Mark Myatt (mark@myatt.demon.co.uk)
Date: Thu 30 May 2002 - 00:18:35 EST


Message-id: <nimBwHA7MO98EwH2@myatt.demon.co.uk>

Sven Garbade <garbade@psy.uni-muenchen.de> writes:
>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
>> x <- 1:10
>> is.integer(x)
>[1] TRUE
>
>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)

That is down to the storage mode. Try:

        x <- 10
        typeof(x)

        y <- 1:10
        typeof(y)

You can test with:

        x == as.integer(x)

Mark

--
Mark Myatt

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Wed 16 Oct 2002 - 11:57:18 EST