[R] Dealing with NA's in a data matrix

Gregor Gorjanc gregor.gorjanc at bfro.uni-lj.si
Thu Dec 6 01:06:00 CET 2007


Henrique Dallazuanna <wwwhsd <at> gmail.com> writes:
>  x[is.na(x)] <- 0
> 
> On 05/12/2007, Amit Patel <amitpatel_ak <at> yahoo.co.uk> wrote:
> > Hi I have a matrix with NA value that I would like to convert these to a
value of 0.
> > any suggestions

also

library(gdata)
x <- matrix(rnorm(16), nrow=4, ncol=4)
x[1, 1] <- NA
NAToUnknown(x, unknown=0)

Gregor



More information about the R-help mailing list