[R] How to replace all <NA> values in a data.frame with another ( not 0) value

Muhammad Rahiz muhammad.rahiz at ouce.ox.ac.uk
Tue May 4 15:20:03 CEST 2010


Hi Nevil,

You can try a method like this

x <- c(rnorm(5),rep(NA,3),rnorm(5)) # sample data
dat <- data.frame(x,x)                       # make sample dataframe
dat2 <- as.matrix(dat)                     # conver to matrix
y <- which(is.na(dat)==TRUE)         # get index of NA values
dat2[y] <- "000/000"                         # replace all na values 
with "000/000"

Muhammad






Nevil Amos wrote:
> I need to replace <NA> occurrences in multiple columns  in a data.frame 
> with "000/000"
>
> how do I achieve this?
>
> Thanks
>
> Nevil Amos
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list