Yes, I was confused: In is.na(x) <-value, value is supposed to be an index vector, clearly stated on the help page. So Bert�s suggestion is the way to go.
Thanks to all, G�ran -----Ursprungligt meddelande----- Fr�n: Bill Dunlap <williamwdun...@gmail.com> Datum: fredag, 16 december 2022 20:15 Till: G�ran Brostr�m <goran.brost...@umu.se> Kopia: r-help@r-project.org <r-help@r-project.org> �mne: Re: [R] is.na()<- on a character vector I think that is.na <http://is.na/><http://is.na/%3e>(x) <- i generally does the same to x as does x[i] <- NA I say 'generally' because some classes (e.g., numeric_version) do not allow x[i]<-NA but do allow is.na <http://is.na/><http://is.na/%3e>(x)<-i. It is possible that some classes mess up this equivalence, but I think that would be considered a bug. -Bill On Fri, Dec 16, 2022 at 10:29 AM G�ran Brostr�m <goran.brost...@umu.se<mailto:goran.brost...@umu.se> <mailto:goran.brost...@umu.se<mailto:goran.brost...@umu.se>>> wrote: I'm confused: > x <- 1:2 > is.na <http://is.na/><http://is.na/%3e>(x) <- 1 > x [1] NA 2 OK, but > x <- c("A", "B") > is.na <http://is.na/><http://is.na/%3e>(x) <- "A" > x A "A" "B" NA What happens? G_ran ______________________________________________ R-help@r-project.org<mailto:R-help@r-project.org> <_blank> mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help <https://stat.ethz.ch/mailman/listinfo/r-help><https://stat.ethz.ch/mailman/listinfo/r-help%3e> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html><http://www.r-project.org/posting-guide.html%3e> and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.