My apologies.
I had an extra argument in the panel.bwplot() function
of my last posting. The correct general code is below.
(The extra argument was for allowing the user to identify
outliers in the boxplots, my own adaptation of the
panel.bwplot() function which I'd be happy to share.)
Hi Sundar:
Nice example of a trellis panel function.
But note:
The boxplots are printed in sorted order of the
factor (y) variable, so you also need to
reorder the y values at which you will print the
median text values.
Just add [order(unique(y))] to reshuffle
the y values in the text() line of your
panel function.
(Try the fuel.frame example with your original
code for an example of what I mean.)
dframe <- data.frame(y = rnorm(100), g = rep(letters[1:4], 25))
bwplot(g ~ y,
data = dframe,
panel = function(x, y) {
q <- round(tapply(x, y, median), 3)
text(q, unique(y)[order(unique(y))] + .15, format(q, nsmall = 3))
panel.bwplot(x, y)
})
bwplot(Type ~ Mileage,
data = fuel.frame,
panel = function(x, y) {
q <- round(tapply(x, y, median), 3)
text(q, unique(y)[order(unique(y))] + .15, format(q, nsmall = 3))
panel.bwplot(x, y)
})
Best
Steven McKinney
Consulting Services
Insightful Corporation
smckinney@insightful.com
tel: (800) 569-0123 x349
tel: (206) 283-8802 x349
fax: (206) 283-8691
Insightful Corporation
1700 Westlake Avenue North, Suite 500
Seattle, Washington 98109-3044 USA
Insightful Corporation (www.insightful.com)
provides analytical solutions leveraging
S-PLUS, StatServer, S-PLUS Analytic Server,
Insightful Miner, and consulting services.
> -----Original Message-----
> From: Sundar Dorai-Raj [mailto:sundar.dorai-raj@pdf.com]
> Sent: Wednesday, May 21, 2003 6:23 AM
> To: Karin
> Cc: s-news@lists.biostat.wustl.edu
> Subject: Re: [S] horizontal boxplot
>
>
>
>
> Karin wrote:
> > Hello,
> >
> > Does anyone know what the command/parameter is in S-Plus to obtain
> > a HORIZONTAL boxplot (instead of a vertical one)?
> > Furthermore I want to display the value of the median for
> each box in
> > the plot. Is that possible with the command text?
> >
> > Thanks!
> >
> > Karin
> >
>
> Forgot to answer your second question:
>
> dframe <- data.frame(y = rnorm(100), g = rep(letters[1:4], 25))
> bwplot(g ~ y,
> data = dframe,
> panel = function(x, y) {
> q <- round(tapply(x, y, median), 3)
> text(q, unique(y) + .15, format(q, nsmall = 3))
> panel.bwplot(x, y)
> })
>
> Best,
> Sundar
>
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu. To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message: unsubscribe s-news
>
|