0
votes

I am trying to assign labels to ggplot2 outliers the way it is specified here:

Labeling Outliers of Boxplots in R

And to create a new outlier column I am using the following code:

splitData %>% 
  group_by(Sample.group) %>%
  mutate(outlier=ifelse(is_outlier(value), value, as.numeric(NA)))

And I am getting the error:

Error in mutate_impl(.data, dots) : Evaluation error: missing values and NaN's not allowed if 'na.rm' is FALSE.

The splitData looks like that:

enter image description here

I guess, wrong as.numeric() happens somewhere; there is a similar thread:

Error: missing values and NaN's not allowed if 'na.rm' is FALSE

But I am having trouble figuring out where. Any suggestions would be greatly appreciated.

1
Please share your data using dput(). Seem more here: How to make a great R reproducible example? - Tung

1 Answers

2
votes

You cannot turn NA values into a number by using as.numeric(NA). You should omit the NA values or impute them if you can. Missing values are always a nuisance but sometimes there is nothing more left to do than dropping the samples (=rows in your case).