Richard A. O'Keefe
2003-Oct-08 21:22 UTC
is.na(v)<-b (was: Re: [R] Beginner's query - segmentation fault)
Simon Fear <Simon.Fear at synequanon.com> suggested that > a<-"a" > a<-NA > mode(a) [1] "logical" > a<-"a" > is.na(a) <- T > mode(a) [1] "character" might be a relevant difference between assigning NA and using is.na. But the analogy is flawed: is.na(x) <- operates on the _elements_ of x, while x <- affects the variable x. When you assign NA to _elements_ of a vector, the mode does not change: > a <- "a" > is.na(a) <- TRUE > mode(a) [1] "character" > b <- "b" > b[TRUE] <- NA > mode(b) [1] "character" > c <- "c" > c[1] <- NA > mode(c) [1] "character"