I have been trying to replace outliers 1.5*IQR +/- upper/lower quantile by the upper and lower quantile with the following code:
`lower.quantile <- as.numeric(summary(loans$dINC_A)[2])
lower.quantile
[1] 9000
upper.quantile <- as.numeric(summary(loans$dINC_A)[5])
> upper.quantile
[1] 21240
IQR <- upper.quantile - lower.quantile
# I replace outliers by the lower/upper bound values
loans$INC_A[ loans$dINC_A < (lower.quantile-1.5*IQR) ] <- lower.quantile
loans$INC_A[ loans$dINC_A > (upper.quantile+1.5*IQR) ] <- upper.quantile`
Moreover:
> upper.quantile+1.5*IQR
[1] 39600
> lower.quantile-1.5*IQR
[1] -9360
However, once I recheck the summary() of my variable, my I get that my maximal value remains 64800>upper.quantile+1.5*IQR=39600
> summary(loans$dINC_A)
Min. 1st Qu. Median Mean 3rd Qu. Max. 0 9000 19500 21240 30600 64800
What is missing in my R code ?