我有一个具有多个异常值的数据框。我怀疑这些 ouliers 产生的结果与预期不同。
我尝试使用这个技巧,但它没有用,因为我仍然有非常不同的值:https ://www.r-bloggers.com/2020/01/how-to-remove-outliers-in-r/
我尝试了使用rstatix
包的解决方案,但我无法从我的 data.frame 中删除异常值
library(rstatix)
library(dplyr)
df <- data.frame(
sample = 1:20,
score = c(rnorm(19, mean = 5, sd = 2), 50))
View(df)
out_df<-identify_outliers(df$score)#identify outliers
df2<-df#copy df
df2<- df2[-which(df2$score %in% out_df),]#remove outliers from df2
View(df2)