Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove outliers in boxplot in R? [duplicate]

Possible Duplicate:
Changing the outlier rule in a boxplot

I need to visualize my result using box-plot.

x<-rnorm(10000) boxplot(x,horizontal=TRUE,axes=FALSE) 

How can i filter outliers during visualisation?

(1) So that i can have full image on screen without having ugly outliers.

http://postimage.org/image/szzbez0h1/a610666d/

(2) Is there any way to show outliers upto certain range? http://postimage.org/image/np28oee0b/8251d102/

Regards

like image 292
Manish Avatar asked Jan 08 '13 03:01

Manish


People also ask

How do I remove outliers from a boxplot in R?

We can remove outliers in R by setting the outlier. shape argument to NA. In addition, the coord_cartesian() function will be used to reject all outliers that exceed or below a given quartile. The y-axis of ggplot2 is not automatically adjusted.

How do I remove multiple outliers in R?

Firstly, we find first (Q1) and third (Q3) quartiles. Then, we find interquartile range (IQR) by IQR() function. In addition, we calculate Q1 – 1.5*IQR to find lower limit and Q3 + 1.5*IQR to find upper limit for outliers. Then, we use subset() function to remove outliers.

How do I remove an outlier from a Dataframe in R?

To remove outliers from a data frame, we use the Interquartile range (IQR) method. This method uses the first and third quantile values to determine whether an observation is an outlier to not.


1 Answers

See ?boxplot for all the help you need.

 outline: if ‘outline’ is not true, the outliers are not drawn (as           points whereas S+ uses lines).  boxplot(x,horizontal=TRUE,axes=FALSE,outline=FALSE) 

And for extending the range of the whiskers and suppressing the outliers inside this range:

   range: this determines how far the plot whiskers extend out from the           box.  If ‘range’ is positive, the whiskers extend to the most           extreme data point which is no more than ‘range’ times the           interquartile range from the box. A value of zero causes the           whiskers to extend to the data extremes.  # change the value of range to change the whisker length boxplot(x,horizontal=TRUE,axes=FALSE,range=2) 
like image 98
thelatemail Avatar answered Oct 13 '22 22:10

thelatemail