I have a dataframe with some numeric columns. Some row has a 0 value which should be considered as null in statistical analysis. What is the fastest way to replace all the 0
An alternative way without the [<- function:
[<-
A sample data frame dat (shamelessly copied from @Chase's answer):
dat
dat x y 1 0 2 2 1 2 3 1 1 4 2 1 5 0 0
Zeroes can be replaced with NA by the is.na<- function:
NA
is.na<-
is.na(dat) <- !dat dat x y 1 NA 2 2 1 2 3 1 1 4 2 1 5 NA NA