[R] questions about boxplots

Stephen D. Weigand weigand.stephen at charter.net
Tue Sep 27 05:16:50 CEST 2005


Dear Yulei,

On Sep 26, 2005, at 6:56 PM, Yulei He wrote:

> Hi, there.
>
> I have two questions about using R to create boxplots.
>
> 1. The function boxplot() plots the outliers. How can I label the exact
> values arount these outlier points? Does R have an option allow me to
> do that?

You can use identify(). Here's a toy example

set.seed(1)
y <- rt(30, 3)
boxplot(y)
identify(x = rep(1,30), y = y, label = format(y, digits = 2))
### now click on the outlier in the plot and you should see "-7.398"
### beside the outlier

> 2. How can I put two boxplots in one x-y axis?

x <- rnorm(10)
y <- rnorm(20, 3, 5)
z <- runif(30)

boxplot(x, y, z, labels = c("x", "y", "z"))
### - or -
boxplot(list(x = x, y = y, z = z))


> Thanks.
>
> Yulei
>

Stephen Weigand
Rochester, Minnesota, USA




More information about the R-help mailing list