Hi: Here's another take with ggplot2:
library(ggplot2) # Define the basic plot elements. First argument is the data frame. # aes() refers to the plot's aesthetics, which refer to the variables # mapped to specific 'roles' in the plot 'geoms' g <- ggplot(x, aes(x = Age, y = Trait)) g + geom_point(size = 2.5) + facet_wrap(~ Group) + theme_bw() geom_point() produces a scatterplot; it picks up its x and y from the aesthetics in g. The default point size in geom_point() is 2, which I upped a bit. facet_wrap() produces individual plots by group; it serves the same purpose as the conditioning variable in lattice. The default theme in ggplot2 is to produce a grey background; theme_bw() changes the background to white and changes a few other defaults. HTH, Dennis On Wed, Oct 27, 2010 at 2:21 AM, Rosario Garcia Gil < m.rosario.gar...@genfys.slu.se> wrote: > Hello > > I have a data set summarized like this: > > File name= Height > > Group Ind Age Trait > 1 1 1 20 > 1 1 2 21 > 1 2 1 22 > 1 2 2 21 > 1 3 1 24 > 1 3 2 45 > 1 4 1 23 > 1 4 2 26 > 2 1 1 45 > 2 1 2 12 > 2 2 1 25 > 2 2 2 26 > 2 3 1 45 > 2 3 2 43 > 2 4 1 23 > 2 4 2 47 > . > . > . > > > I would like to plot Trait ~ Age but a different plot for each Group. > I tried: > > plot(Height$Trait ~ Height$Age | Group) > > But does not work. Any suggestion? > > Thanks > Rosario > > ______________________________________________ > 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. > [[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.