I want to clean my data in one go, but the following code doesn't work. Data has factor features and numeric features as well.
findnullna <- function(x){
for(i in 1:length(x)){
if(x[i]=="" | x[i]=="NULL" | x[i]=="#N/A" | x[i]=="#NAME?"){
x[i]<- NA
}
}
return(x)
}
df <- sapply(df,findnullna)
I get an error
Error in if (x[i] == "" | x[i] == "NULL" | x[i] == "#N/A" | x[i] == "#NAME?") { : missing value where TRUE/FALSE needed
also sometimes I get
Error in x[i] : object of type 'symbol' is not subsettable
Aucun commentaire:
Enregistrer un commentaire