Is there an easy way to make graphs for the following data. I have pretest and posttest scores for men and women. I would like to form a 'titlted segment' plot for the data. That is, make segments joining the scores, with different types of segments for men and women. Example data: menpre <- c(43,42,26,39,60,60,46) menpost <- c(40,41,36,42,54,58,43) womenpre <- c(46,56,81,56,70,70) womenpost <- c(44,52,81,59,69,68) Thanks! Juliet
?plot ?lines Something like this perhaps plot( menpre, type="l", col="red") lines(menpost, col="blue") lines(womenpre,col="green" lines(womenpost, col= "orange") also have a look at ?par for various options --- On Sat, 8/23/08, Juliet Hannah <juliet.hannah at gmail.com> wrote:> From: Juliet Hannah <juliet.hannah at gmail.com> > Subject: [R] graphs for pretest data > To: r-help at r-project.org > Received: Saturday, August 23, 2008, 12:04 PM > Is there an easy way to make graphs for the following data. > I have > pretest and posttest scores for men and > women. I would like to form a 'titlted segment' > plot for the data. > That is, make segments joining the scores, > with different types of segments for men and women. > > Example data: > > menpre <- c(43,42,26,39,60,60,46) > menpost <- c(40,41,36,42,54,58,43) > > womenpre <- c(46,56,81,56,70,70) > womenpost <- c(44,52,81,59,69,68) > > Thanks! > > Juliet > > ______________________________________________ > 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.__________________________________________________________________ [[elided Yahoo spam]]
Dear Juliet,
Perhaps start here:
require(lattice)
mwpp <- data.frame(y = c(43,42,26,39,60,60,46,40,41,36,42,54,
58,43,46,56,81,56,70,70,44,52,81,59,69,68),
sex = rep(c(rep('men', 14), rep('women', 12))),
pp = c(rep(c('pre', 'post'), each = 7), rep(c('pre',
'post'), each =
6)),
sub = c(1:7, 1:7, 8:13, 8:13))
xyplot(y ~ pp | sex, groups = sub, type = 'b', mwpp)
_____________________________
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400 Charlottesville, VA 22904-4400
Parcels: Room 102 Gilmer Hall
McCormick Road Charlottesville, VA 22903
Office: B011 +1-434-982-4729
Lab: B019 +1-434-982-4751
Fax: +1-434-982-4766
WWW: http://www.people.virginia.edu/~mk9y/
On Aug 23, 2008, at 12:04 PM, Juliet Hannah wrote:
> Is there an easy way to make graphs for the following data. I have
> pretest and posttest scores for men and
> women. I would like to form a 'titlted segment' plot for the data.
> That is, make segments joining the scores,
> with different types of segments for men and women.
>
> Example data:
>
> menpre <- c(43,42,26,39,60,60,46)
> menpost <- c(40,41,36,42,54,58,43)
>
> womenpre <- c(46,56,81,56,70,70)
> womenpost <- c(44,52,81,59,69,68)
>
> Thanks!
>
> Juliet
[[alternative HTML version deleted]]
On Sat, 2008-08-23 at 12:04 -0400, Juliet Hannah wrote:> Is there an easy way to make graphs for the following data. I have > pretest and posttest scores for men and > women. I would like to form a 'titlted segment' plot for the data. > That is, make segments joining the scores, > with different types of segments for men and women. > > Example data: > > menpre <- c(43,42,26,39,60,60,46) > menpost <- c(40,41,36,42,54,58,43) > > womenpre <- c(46,56,81,56,70,70) > womenpost <- c(44,52,81,59,69,68) >Hi Juliet, This looks like spread.labels in the plotrix package might do the job. Check the second example. Jim