Replace NaN values in a list with zero (0)
问题 Hi dear I have a problem with NaN . I am working with a large dataset with many variables and they have NaN . The data is like this: z=list(a=c(1,2,3,NaN,5,8,0,NaN),b=c(NaN,2,3,NaN,5,8,NaN,NaN)) I used this commands to force the list to data frame but I got this: z=as.data.frame(z) > is.list(z) [1] TRUE > is.data.frame(z) [1] TRUE > replace(z,is.nan(z),0) Error en is.nan(z) : default method not implemented for type 'list' I forced z to data frame but it wasn't enough, maybe there is a form to