Pesumably because v[1] <- 0 give a numeric result, then the rest of v is coerced into numeric.
Observe v <- 0:10 class(v) v[1] <- as.integer(0) class(v[1]) class(v) --- On Wed, 8/5/09, Steve Jaffe <sja...@riskspan.com> wrote: > From: Steve Jaffe <sja...@riskspan.com> > Subject: [R] why is 0 not an integer? > To: r-help@r-project.org > Received: Wednesday, August 5, 2009, 4:16 PM > > 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 > > class(v) > [1] "numeric" #!! > > > > -- > View this message in context: > http://www.nabble.com/why-is-0-not-an-integer--tp24835423p24835423.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org > mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. > __________________________________________________________________ The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Fr ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.