mercredi 20 février 2019

If statement Error : argument is of length zero

I am using an If statement in R to check if value of a var is zero. If it's zero, then assign earlier value to it.

But it's raising error. I am not able to remove it:

Error in if (var3 == 0) { : argument is of length zero

Here is my code:

outliers <- boxplot(outlier_rem$var3, plot=FALSE)$out
ol <- outlier_rem[which(-outlier_rem$var3 %in% outliers),]
AV <- ol$var3

if (var3 == 0) { 
  var3 <- outlier_rem$var3 
}

desc(var3)

EDIT

In the code, outlier_rem is my data frame that contains fewer then 20 vars. var3 is one of the var. It has 14000 entries and values are like 55.45, 45.34. In this case, I detected outliers in it and that are zero. So it has zero value here.

Aucun commentaire:

Enregistrer un commentaire