[R] Setting NA to blank

John Kane jrkrideau at yahoo.ca
Mon May 9 21:25:54 CEST 2011


(mat <- matrix(c(1,2,3,NA),2))
mat[is.na(mat)]   <- " "
mat

But if you have a numerical matrix it coverts the matrix to character.

--- On Mon, 5/9/11, Dat Mai <dat.d.mai at gmail.com> wrote:

> From: Dat Mai <dat.d.mai at gmail.com>
> Subject: [R]  Setting NA to blank
> To: r-help at r-project.org
> Received: Monday, May 9, 2011, 2:46 PM
> Hey All,
> 
> I have a matrix m, and I wish to set all the NA values to
> blank. How would I
> do so?
> 
> -- 
> Best,
> Dat Mai
> PhD Rotation Student
> Albert Einstein College of Medicine



More information about the R-help mailing list