I have 9 univariate outliers in my dataframe.
I need to make "tuck" those outliers so that they would fit inside 3 standard deviations from the mean, of basically have them assigned the value of the 5th percentile if they're outside the lower limit, and the value of the 95th percentile if they're outside the upper limit.
I tried this code:
x <- ozone$pressure_height qnt <- quantile(x, probs=c(.25, .75), na.rm = T) caps <- quantile(x, probs=c(.05, .95), na.rm = T) H <- 1.5 * IQR(x, na.rm = T) x[x < (qnt - H)] <- caps x[x > (qnt + H)] <- caps
with my own data, but it doesn't change anything in my dataframe, and after plotting it the outliers remain the same.
I don't want to remove the outliers - just change their values.
Any help is appreciated!