[R] Boxplot Labels

David L Carlson dcarlson at tamu.edu
Tue Apr 9 18:56:32 CEST 2013


The problem is that identify() is designed for a scatterplot not a boxplot.
You can use it but you have to feed it the correct x and y coordinates:

identify(rep(1, nrow(DATA)), DATA$ave, cex=.7)

This will give you "26" as you requested if you click on the outlying point.
That is the row name for the point. You specified DATA$num as your labels,
but they are the same as the row names so there is no need to add that. You
can also identify points at the whiskers, hinges, or median, but they will
probably overprint the lines.

I wasn't sure if your definition of num was intentional or a mistype, eg:

> num <- as.numeric(seq(100:125))
> num
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25
[26] 26
> num <- as.numeric(seq(100, 125))
> num
 [1] 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
118
[20] 119 120 121 122 123 124 125
>

If you wanted the numbers from 1 to 26, num <- 1:26 would be more compact.

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352



> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of John Kane
> Sent: Tuesday, April 09, 2013 10:45 AM
> To: Beatriz González Domínguez; R Help; r-help at r-project.org
> Subject: Re: [R] Boxplot Labels
> 
>   p <- boxplot(dat1$ave, data= dat1, main= "Average Size", yaxt = "n")
>   text(1.1, , y  = max(datDAT1$ave), label = "26", cex = .7)
> 
> but I don't understand
>  #I would like the labels that appear in the boxplot to be DATA$num
> values.
> 
> You want 26 values potted?
> 
> 
> 
> John Kane
> Kingston ON Canada
> 
> 
> > -----Original Message-----
> > From: aguitatierra at hotmail.com
> > Sent: Tue, 9 Apr 2013 16:17:01 +0100
> > To: r-help-bounces at r-project.org, r-help at r-project.org
> > Subject: [R] Boxplot Labels
> >
> > #Dear all,
> >
> > #Could anyone help me with the following?
> > #DATA
> > num <- as.numeric(seq(100:125))
> > ave <- c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5,
> 2.7,
> > 3.1, 2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7)
> > DATA <- data.frame(cbind(num, ave))
> > rm(num, ave)
> >
> > #BOXPLOT
> > x11()
> > bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
> > identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7)
> > #I would like the labels that appear in the boxplot to be DATA$num
> > values.
> > #When I identify the outlier it appears a "1" when I would like to
> appear
> > a "26"
> >
> > #Do you have any idea of how I could do that?
> >
> > #Many thanks!
> > #Bea
> > 	[[alternative HTML version deleted]]
> >
> > ______________________________________________
> > 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.
> 
> ____________________________________________________________
> FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on
> your desktop!
> 
> ______________________________________________
> 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