[R] How to replace all <NA> values in a data.frame with another ( not 0) value
Nevil Amos
nevil.amos at gmail.com
Wed May 5 06:49:10 CEST 2010
Thanks, this works, replacing the NA values with the "000/000' string.
On 4/05/2010 11:20 PM, Muhammad Rahiz wrote:
> 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