[R] is.na()<- on a character vector
Bill Dunlap
w||||@mwdun|@p @end|ng |rom gm@||@com
Fri Dec 16 20:14:24 CET 2022
I think that
is.na(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(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.brostrom using umu.se>
wrote:
> I'm confused:
>
> > x <- 1:2
> > is.na(x) <- 1
> > x
> [1] NA 2
>
> OK, but
>
> > x <- c("A", "B")
> > is.na(x) <- "A"
> > x
> A
> "A" "B" NA
>
> What happens?
>
> G_ran
>
> ______________________________________________
> R-help using 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.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list