[R] replace NULL with NA in matrix

Katharine Mullen kate at few.vu.nl
Thu Apr 17 15:40:35 CEST 2008


if your matrix is stored in a text file then
 xx <- read.table("x", na.strings="NULL")
where "x" is the name of the text file.

On Thu, 17 Apr 2008, Tim Smith wrote:

> Hi,
>
> I had a matrix with NULL values, which I wanted to replace with NA. Is there an efficient way to do this?
>
> Small sample input matrix:
>         A       B       C       D       E
> 1 5222.18 6355.10 4392.68 2607.41 4524.09
> 2    NULL  257.33    NULL  161.51  119.44
> 3    NULL  274.80  305.28  443.27    NULL
> 4 1759.76 1556.45 1224.06 1558.73 1837.09
>
>
> Tim
>
>
>
>
>
>       ____________________________________________________________________________________
> Be a better friend, newshound, and
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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