0

I am trying to convert NaN into zeroes. And, the code I am using is as follows

myfiles6 <- lapply(myfiles6, function(x) {x[is.nan(x)] <- 0; x})

but it gives an error as

Error in is.nan(x) : default method not implemented for type 'list'

What could be the solution?

M--
  • 20,766
  • 7
  • 52
  • 87
ambrish dhaka
  • 653
  • 7
  • 21

1 Answers1

0

Try using the following code:

is.nan.data.frame <- function(x)
  do.call(cbind, lapply(x, is.nan))

myfile6[is.nan(myfile6)] <- 0