Skip to content

Boxplot graphic

5 messages · phillen, John Kane, John Fox +2 more

#
Dear R-users!

I boxplotted some data. the class of the data is numeric. There are some
outliers and I would like to see their names in the graphic. So, instead
that the data points of the outliers are plotted as points, I would like to
have their names plotted.

First of, how can I give my data series (class numeric) names? Second, how
could I adjust the boxplot to see the names of the outliers in the graphic
instead of the points?

cheers



--
View this message in context: http://r.789695.n4.nabble.com/Boxplot-graphic-tp4637761.html
Sent from the R help mailing list archive at Nabble.com.
#
PLEASE do read the posting guide.

You really need to supply some sample data and the code you are using.  We can make guesses about what you are doing but it is much easier to actually look at the data and code.

Please use dput()  ( see ?dput) to supply some sample data.

John Kane
Kingston ON Canada
____________________________________________________________
GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
Works with AIM?, MSN? Messenger, Yahoo!? Messenger, ICQ?, Google Talk? and most webmails
#
Dear phillen,

You can use the identify() command following boxplot() to identify outliers, or more simply, the Boxplot() function in the car package, which will do this for you (see the first example in ?Boxplot).

I hope this helps,
 John

------------------------------------------------
John Fox
Sen. William McMaster Prof. of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

On Wed, 25 Jul 2012 04:26:30 -0700 (PDT)
phillen <phlentner at gmail.com> wrote:
#
On 25.07.2012 13:26, phillen wrote:
See ?names
See ?boxplot

Example:

x <- c(1:10, 100)
names(x) <- letters[1:11]
bp <- boxplot(x)
text(1, bp$out, names(x)[bp$out==x], pos=2)
#
Probably the simplest answer is to google 'label boxplot outliers in R'. I found half a dozen solutions, (one of them my own, but that doesn't quite answer your question).

Adding names to a series of data can be as simple as saying
names(x) <- paste("x", 1:length(x))

After that, the solutions google finds answer the question.

One tip: If you want to _replace_ points with names, plot the boxplot with pch=NA (eg
bx <- boxplot(x~g, pch=NA)
to get the boxplot without outliers but with space for them, and then use text(bx$group, bx$out, ...) or similar to put the names in. If you want boxplot to return names, though, you will need to use a modified boxplot function. The first answer Google returns is one such.

S Ellison
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}