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--
  • 25,431
  • 8
  • 61
  • 93
ambrish dhaka
  • 689
  • 7
  • 27

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