[R] means and error bars on xyplot for binary data

From: Louis Plough <lplough_at_usc.edu>
Date: Tue, 28 Jun 2011 00:12:00 -0700

I have binary (0,1) data for a trait as my response variable, and a dependent variable, genotype, with three classes (AA, AB, BB).

I would like to plot this data so that across the three genoytpes, even though the points are all either 0 or 1, i want them to stack up or be seen using 'jitter'. So far I have been able to do this using xyplot {lattice} (code below) but could not get the points to jitter or stack up on boxplot or bwplot {lattice}.

 I would also like to add to the xyplot object, the mean of the values at each of these classes which will vary depending on how many data points are at 0 and 1 for a given genotype. I would also like to put error (i.e. standard error) bars around these estimates.

I have tried using the points() function to put the mean at each of the genotype classes, but the point ends up off the figure. Any ideas how to get this going?

here is some example code.

> gtype<-c("AA","AB","BB")
xyplot(y~x, jitter.y=TRUE, jitter.x=TRUE,factor=.6, data=bin.data)

Then If I wanted to add the means to the plot, I would do this, which will print the mean points on a box plot, but not an xyplot:

means1 <- tapply(bin.data$y,bin.data$x,mean) points(means1,col="red",pch=18)

Is there a way to get the means, and even error bars on the same xyplot?

Thanks for any help in advance,

        [[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. Received on Tue 28 Jun 2011 - 07:14:32 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 28 Jun 2011 - 19:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive