I'm trying to delete outliers from my dataset, using iqr. I got iqr value for each column in my dataframe and now i want to exclude from the dataframe all the values that are outliers.
My code is:
> q1 <- colwise(quantile)(completeData, probs = c(.25))
> q2 <- colwise(quantile)(completeData, probs = c(.75))
> IQR <- q2 - q1
> IQR
MinTemp MaxTemp Rainfall Evaporation Sunshine WindGustSpeed WindSpeed9am WindSpeed3pm Humidity9am Humidity3pm Pressure9am Pressure3pm Cloud9am Cloud3pm Temp9am Temp3pm RainToday Date Location
1 9.2 10.3 2.2 4.4 7.1 19 8 11 26 31 9.6 9.7 5 4 9.3 9.9 1 1537 25
WindGustDir WindDir3pm RainTomorrow
1 9 8 1
Now that i have iqr values for each variable in the dataframe i want to exclude outliers this way:
completeData <- subset(completeData, completeDat > (q1 - 1.5*IQR) & completeData < (q2+1.5*IQR))
This last line is just to let you understand the idea. The code of the last line is not working and i just want something that can help me delete all outliers from each column of the data frame.
Thanks in advance to who will help me out.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…