[R] How to return/show the indexes of unusual points in boxplot?

guox at ucalgary.ca guox at ucalgary.ca
Wed Sep 9 22:47:49 CEST 2009


Thanks for your help.
-jmaes
> Hi James,
> If that's the case, then
>
> set.seed(123)
> x <- c(4,rnorm(20),8)
> bp <- boxplot(x)
> bp$out
> # [1] 4 8
> which(x %in% bp$out)
> # [1]  1 22
>
> is what you are looking for.  :-)
>
> HTH,
> Jorge
>
>
> On Wed, Sep 9, 2009 at 4:07 PM, <guox at ucalgary.ca> wrote:
>
>> Thank you very much.
>> But it seems that
>> x$out returns the values not the indexes of the  values (1,22).
>> -james
>>
>> > boxplot returns a dataframe that has the values in it at "$out":
>> >
>> >> x <- boxplot(c(4,rnorm(20),8))
>> >> x
>> > $stats
>> >            [,1]
>> > [1,] -1.5364498
>> > [2,] -0.5282799
>> > [3,] -0.1398736
>> > [4,]  0.3065579
>> > [5,]  1.3430388
>> >
>> > $n
>> > [1] 22
>> >
>> > $conf
>> >            [,1]
>> > [1,] -0.4210947
>> > [2,]  0.1413474
>> >
>> > $out
>> > [1] 4 8
>> >
>> > $group
>> > [1] 1 1
>> >
>> > $names
>> > [1] "1"
>> >
>> >
>> >
>> > On Wed, Sep 9, 2009 at 3:25 PM, <guox at ucalgary.ca> wrote:
>> >> I am wondering if you know how to return by function or show in
>> >> boxplot,
>> >> the indexes of unusual points, such as,
>> >> points that are outside the box or in [Q3+1.5IQR,Max].
>> >> For example,
>> >>
>> >>> boxplot(c(4,rnorm(20),8))
>> >>
>> >> There are 2 unusual points 4 and 8. How to show the indexes of 4 and
>> 8
>> >> in
>> >> the boxplot
>> >> or return them by function?
>> >>
>> >> Thanks,
>> >>
>> >> -james
>> >>
>> >> ______________________________________________
>> >> R-help at r-project.org mailing list
>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>> >> PLEASE do read the posting guide
>> >> http://www.R-project.org/posting-guide.html
>> >> and provide commented, minimal, self-contained, reproducible code.
>> >>
>> >
>> >
>> >
>> > --
>> > Jim Holtman
>> > Cincinnati, OH
>> > +1 513 646 9390
>> >
>> > What is the problem that you are trying to solve?
>> >
>> >
>> >
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>




More information about the R-help mailing list