# Generate a demo data
set.seed(123)
demo.data <- data.frame(
sample = 1:20,
score = c(rnorm(19, mean = 5, sd = 2), 50),
gender = rep(c("Male", "Female"), each = 10)
)
# Identify outliers according to the variable score
demo.data %>%
identify_outliers(score)
# Identify outliers by groups
demo.data %>%
group_by(gender) %>%
identify_outliers("score")
Run the code above in your browser using DataLab