dimanche 27 juin 2021

Showing lowest outliers

I'm currently looking to return the lowest outlier in my dataset and when there is no outlier the script should return "No outliers". The problem is I get an error message "Error in vec_minout[[n]] <- paste(names(london[[n]]), outs, outlier, sep = ", ") : more elements supplied than there are to replace"

Any help?

vec_minout <- NA

for (n in seq_along(london)) { 
  if  (class(london[[n]]) == "numeric") {
   outs <- boxplot(london[[n]], plot=FALSE)$out
    outlier <- min(london[[n]], na.rm = TRUE)
    vec_minout[[n]] <- paste(names(london[[n]]), outs, outlier, sep = ", ") 
  }
  else {
    vec_minout[[n]] <- tail(names(sort(table(london[[n]]))), 1, )

   
    
  }
}

vec_minout

Aucun commentaire:

Enregistrer un commentaire