This automates things a bit once we re-organize your data. my.newdata <- stack(data.frame(my.data), select=c(Control, Case)) stripchart(values~ind, my.newdata, method = "stack", offset=1/3, vertical = TRUE, pch=19) medians <- tapply(my.newdata$values, my.newdata$ind, median) points(c(1, 2), medians, pch="-", cex=3, col="red")
---------------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -----Original Message----- > From: Luigi [mailto:marongiu.lu...@gmail.com] > Sent: Wednesday, June 13, 2012 6:44 PM > To: dcarl...@tamu.edu > Cc: r-help@r-project.org > Subject: RE: [R] Median line with stripchart > > Sorry for the inconvenience, > I have added an EXAMPLE. Here I am plotting few data with the relative > median values. The median are added ad hoc using the points() function, > which is not really professional and is time consuming. With boxplot() > the > median values are automatically drawn, with striplot() this is not true > and > I couldn't find another suitable package. > Note: usually I work with data frames and the group names is plotted > correctly; here I have added the group names with text(). > > Thank you, > Regards, > Luigi > > ########### THE EXAMPLE > ####################################################################### > ##### > ############# > # assigning data > Control<-c(0.002325138, 0.002460417, 0.010971385, 0.033016026, > 0.035646472, > 3.161701212, 5.10096383, 5.327863403) > Case<-c(0.000142311, 0.010751273, 0.151395382, 0.153094117, > 0.381564497, > 1.32567787, 2.915908912, 14.2888441) > my.data<-cbind(Control, Case) > Med.Control<-0.034331249 > Med.Case<-0.267329307 > > > # plotting data > stripchart(Control, method = "stack" , offset=1/3, vertical = TRUE, > pch=19, > at=0.5) > stripchart(Case, method = "stack" , offset=1/3, vertical = TRUE, > pch=19, > at=1.5,add=TRUE) > > # adding text > text(0.7, 0, labels = "Controls") > text(1.7, 0, labels = "Cases") > > # adding median values > points(0.5, Med.Control, pch="-", cex=3, col="red") > points(1.5, Med.Case, pch="-", cex=3, col="red") > > ####################################################################### > ##### > ##################################### > > > -----Original Message----- > From: David L Carlson [mailto:dcarl...@tamu.edu] > Sent: 13 June 2012 17:29 > To: 'Luigi'; r-help@r-project.org > Subject: RE: [R] Median line with stripchart > > It would help if you would give us a copy of at least part of the data > you > are using and show us what you have tried so far. This is a simple > example. > In this case the median is for the entire data set not for a single > group. > But you really didn't give us enough information. > > x <- rnorm(75) > g <- rep(1:3, 25) > stripchart(x~g) > abline(v=median(x), lty=2) > > ---------------------------------------------- > David L Carlson > Associate Professor of Anthropology > Texas A&M University > College Station, TX 77843-4352 > > > > -----Original Message----- > > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > > project.org] On Behalf Of Luigi > > Sent: Wednesday, June 13, 2012 10:57 AM > > To: r-help@r-project.org > > Subject: [R] Median line with stripchart > > > > Dear all, > > > > I would like to ask if it possible to draw a median line in a > > Stripchart, > > either using the built-in STRIPCHART function or with another > package. > > > > I was expecting stripchart() to work more or less like boxplot(), but > I > > couldn't find an easy way to draw a mean or median line, neither I > > found > > this option in other packages. > > > > Could somebody help? > > > > Best regards, > > > > > > > > Luigi Marongiu, MSc > > > > > > > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@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. ______________________________________________ R-help@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.