[R] lattice command equivalent to points
Deepayan Sarkar
deepayan.sarkar at gmail.com
Wed Sep 3 06:46:36 CEST 2008
On 9/2/08, Steven McKinney <smckinney at bccrc.ca> wrote:
>
>
> This is close, but maybe not optimal lattice coding.
> I haven't yet figured out how to suppress the x axis
> labeling.
>
> bwplot(yield ~ 1|year, panel = function(x, y, ...){panel.bwplot(x, y, ..., pch = "|"); panel.points(x, mean(y), ..., pch=17)}, data = barley, horizontal = FALSE, xlab = "")
>
A direct translation would be
bwplot(yield ~ year, data = barley, horizontal = FALSE,
panel = function(x, y, ...) {
panel.bwplot(x, y, ..., pch = "|");
mean.values <- tapply(y, x, mean)
panel.points(1:2, mean.values, ..., pch = 17)
})
and that seems to work.
-Deepayan
> Steve McKinney
>
>
>
> -----Original Message-----
> From: r-help-bounces at r-project.org on behalf of Surai
> Sent: Tue 9/2/2008 5:53 PM
> To: r-help at r-project.org
> Subject: [R] lattice command equivalent to points
>
> Hello,
> This is my first post to R-help so forgive me if I'm committing a fatal error somehow. Feel free to let me know.
>
> My question is this: I would like to add a triangle to represent the mean in a box plot generated with the bwplot command. How do I do this? I am able to do this using the boxplot and points command but points does not work with bwplot. If you run the following code in R, you'll see that I'm trying to reproduce graphs from method 2 by modifying code from method 1.
>
> Thank you,
> Surai Jones
>
>
> library(lattice)
> attach(barley)
>
> #method 1
> bwplot(yield~year, pch="|")
>
> #method 2
> boxplot(yield~year)
> mean.values<-tapply(yield,year, mean)
> points(1:2, mean.values, pch = 17)
>
>
>
> [[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.
>
More information about the R-help
mailing list