[R] why is 0 not an integer?
Nikos Alexandris
nikos.alexandris at felis.uni-freiburg.de
Wed Aug 5 22:22:31 CEST 2009
On Wed, 2009-08-05 at 13:16 -0700, Steve Jaffe wrote:
> Why when I assign 0 to an element of an integer vector does the type change
> to numeric?
> Here is a particularly perplexing example:
> > v <- 0:10
> > v
> [1] 0 1 2 3 4 5 6 7 8 9 10
> > class(v)
> [1] "integer"
> > v[1] <- 0
try this:
v <- as.integer(0)
Nikos
> > class(v)
> [1] "numeric" #!!
> >
>
More information about the R-help
mailing list