I am currently trying to remove outliers in R in a very easy way. I know there are functions you can create on your own for this but I would like some input on this simple code and why it does not seem to work?
outliers <- boxplot(okt$pris)$out
okt_no_out <- okt[-c(outliers),]
boxplot(okt_no_out$pris)
The first row I create a vector with the outliers, the second I create a new dataframe omitting the values in that vector. But... When I check the new dataframe only about 400 of the 750 outliers were removed?
The vector outliers contain roughly 750 rows, but when doing this it only remove about half of them....
Should not these simple lines of code remove the outliers in a very convenient way?