As part of my data analysis workflow, I want to test for outliers, and then do my further calculation with and without those outliers.
I\'ve found the outlier pack
Try the outliers::score function. I don't advise removing the so called outlier's, but knowing your extreme observations is good.
library(outliers)
set.seed(1234)
x = rnorm(10)
[1] -1.2070657 0.2774292 1.0844412 -2.3456977 0.4291247 0.5060559 -0.5747400 -0.5466319
[9] -0.5644520 -0.8900378
outs <- scores(x, type="chisq", prob=0.9) # beyond 90th %ile based on chi-sq
#> [1] FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
x[outs] # most extreme
#> [1] -2.345698
You'll find more help with outlier detection here