[R] Replace NaN with zero

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Nov 25 10:01:23 CET 2008



Spilak,Jacqueline [Edm] wrote:
> I need help with replacing NaN with zero (the value '0') in my dataset.
> The reason is that I can't get it to graph because of the NaN in the
> dataset.  I have tried: 
> data[is.nan(data)] <- 0

Since data is a data.frame and not a matrix, you might want to loop over 
  its columns and apply your replacement for each column separately.

Uwe Ligges


> that others have suggested in the help archives but this does nothing so
> I am not sure what I am doing wrong.
> Thanks in advance for your help. 
> 
> 	[[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