[R] integer
GÃ¶ran BrostrÃ¶m
gb at stat.umu.se
Tue Nov 2 14:41:29 CET 2004
On Tue, Nov 02, 2004 at 11:36:27AM +0100, Uwe Ligges wrote:
> Ludovic Tambour wrote:
>
> >Hello,
> >
> >I need to use "R" to determine parameters which are integers. How I can do
> >this, please ?
>
> What so you mean with "parameters"? In which context?
>
> To check whether a numeric vector "x" contains only integers, you can try
>
> all.equal(as.integer(x), x)
I don't think so:
> x <- as.double(c(1, 2))
> y <- as.integer(c(1, 2))
> all.equal(x, y)
[1] TRUE
But,
> identical(x, y)
[1] FALSE
On the other hand, why not use
> is.integer(x)
[1] FALSE
> is.integer(y)
[1] TRUE
because I think that a numeric vector can't have a mix of integer and
non-integer elements. With a list it's a different story.
GÃ¶ran
--
GÃ¶ran BrostrÃ¶m tel: +46 90 786 5223
Department of Statistics fax: +46 90 786 6614
UmeÃ¥ University http://www.stat.umu.se/egna/gb/
SE-90187 UmeÃ¥, Sweden e-mail: gb at stat.umu.se
More information about the R-help
mailing list