[R] Boxplot Labels

Rui Barradas ruipbarradas at sapo.pt
Tue Apr 9 18:31:40 CEST 2013


Hello,

The construct data.frame(cbind(...)) is not at all needed, the following 
is much better.

dat1 <- data.frame(num, ave)


Also, I've modified the text() call a bit, in order to have R tell the 
dat1$num corresponding to the (unique) max of ave, and with an extra 
argument, pos. This would allow for placement of the label near the point.

p <- boxplot(dat1$ave, data= dat1, main= "Average Size", yaxt = "n")
text(1, , y = max(dat1$ave), label = dat1$num[which.max(dat1$ave)], cex 
= .7, pos = 4)


Hope this helps,

Rui Barradas


Em 09-04-2013 16:44, John Kane escreveu:
>    p <- boxplot(dat1$ave, data= dat1, main= "Average Size", yaxt = "n")
>    text(1.1, , y  = max(dat1$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