What you should keep in mind is that a matrix in R is nothing more than a
vector (formed by stacking the columns of the matrix) with the dim
attribute.  Thus you can do what you want to do by treating the matrix as a
vector; e.g.,

mymat[is.na(mymat)] <- myFavoriteValue

HTH,
Andy


> From: michael watson (IAH-C)
> 
> OK, dumb question, and it is probably in the docs somewhere, but after
> 12 months working with R and quite a while looking at the 
> docs, I still
> don't know (or have forgotten) how to replace all NA values 
> in a matrix
> at once with some other value.  I can do it column by column using
> is.na(), but I can't figure out how to do it for the whole matrix.  My
> apologies, I am ashamed ;-)
> 
> Michael Watson
> Head of Informatics
> Institute for Animal Health,
> Compton Laboratory,
> Compton,
> Newbury,
> Berkshire RG20 7NN
> UK
> 
> Phone : +44 (0)1635 578411 ext. 2535
> Mobile: +44 (0)7990 827831
> E-mail: [EMAIL PROTECTED]
> 
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to