[R] a question about boxplot

Jim Lemon jim at bitwrit.com.au
Fri Feb 14 09:59:54 CET 2014


On 02/14/2014 07:52 PM, Bogdan Tanasa wrote:
> Dear all,
>
> a simple question about boxplot() function,
> on how not to display a set of values (outliers), but keep the same median
> of the original dataset on the display ;
>
> more precisely :
>
>
> given a dataset : 1,2,3,4,5,6, 100, 200,300
> the median is : 5
>
> after removing the extreme values : 100, 200, 300
> the median is 3.5,
>
> but would still like to display a boxplot with median of 5. would this be
> possible ? thank you !
>
Hi bogdan,
You could do something like this:

x<-c(1,2,3,4,5,6,100,200,300)
x_box<-boxplot(x,plot=FALSE)
x_box$stats<-matrix(c(1,3,5,5.5,6),ncol=1)
x_box$out<-NA
bxp(x_box)

Note that the "box" may not represent what you want.

Jim




More information about the R-help mailing list