You could use one of map
functions :
library(rstatix)
library(tidyverse)
map_df(names(select(iris, Sepal.Length:Petal.Width)), ~{
iris %>%
group_by(Species) %>%
identify_outliers(all_of(.x))
})
# Species Sepal.Length Sepal.Width Petal.Length Petal.Width is.outlier is.extreme
# <fct> <dbl> <dbl> <dbl> <dbl> <lgl> <lgl>
# 1 virginica 4.9 2.5 4.5 1.7 TRUE FALSE
# 2 setosa 5.7 4.4 1.5 0.4 TRUE FALSE
# 3 setosa 4.5 2.3 1.3 0.3 TRUE FALSE
# 4 virginica 7.7 3.8 6.7 2.2 TRUE FALSE
# 5 virginica 6 2.2 5 1.5 TRUE FALSE
# 6 virginica 7.9 3.8 6.4 2 TRUE FALSE
# 7 setosa 4.3 3 1.1 0.1 TRUE FALSE
# 8 setosa 4.6 3.6 1 0.2 TRUE FALSE
# 9 setosa 4.8 3.4 1.9 0.2 TRUE FALSE
#10 setosa 5.1 3.8 1.9 0.4 TRUE FALSE
#11 versicolor 5.1 2.5 3 1.1 TRUE FALSE
#12 setosa 5.1 3.3 1.7 0.5 TRUE FALSE
#13 setosa 5 3.5 1.6 0.6 TRUE TRUE
Similarly, using imap_dfr
:
imap_dfr(select(iris, Sepal.Length:Petal.Width), ~{
iris %>%
group_by(Species) %>%
identify_outliers(all_of(.y))
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…