I tried to replace NaN values with zeros using the following script:
NaN
rapply( data123, f=function(x) ifelse(is.nan(x),0,x), how=\"replace\" ) #
The following should do what you want:
x <- data.frame(X1=sample(c(1:3,NaN), 200, replace=TRUE), X2=sample(c(4:6,NaN), 200, replace=TRUE)) head(x) x <- replace(x, is.na(x), 0) head(x)