is.na(v)<-b (was: Re: [R] Beginner's query - segmentation fault)
Richard A. O'Keefe
ok at cs.otago.ac.nz
Wed Oct 8 23:22:46 CEST 2003
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"
More information about the R-help
mailing list