Søren Højsgaard
2006-Aug-29 19:59 UTC
[R] lattice/xyplot: plotting 4 variables in two panels - can this be done?
Hi, I would like to create a plot of y1,y2,y3,y4 against x for several subjects such that y1 and y2 are plotted against x in one panel and y3 and y4 against x in another panel. Thus if there are 3 subjects I should end up with 6 panels. Is there a simple way of doing so (i.e. without calling xyplot() several times, and then padding the results together)?? Regards S?ren
Deepayan Sarkar
2006-Aug-29 22:54 UTC
[R] lattice/xyplot: plotting 4 variables in two panels - can this be done?
On 8/29/06, S?ren H?jsgaard <Soren.Hojsgaard at agrsci.dk> wrote:> Hi, > I would like to create a plot of y1,y2,y3,y4 against x for several subjects such that y1 and y2 are plotted against x in one panel and y3 and y4 against x in another panel. Thus if there are 3 subjects I should end up with 6 panels. Is there a simple way of doing so (i.e. without calling xyplot() several times, and then padding the results together)??You need to transform your data into a suitable form. See ?reshape and ?make.groups. Deepayan
Gabor Grothendieck
2006-Aug-30 00:56 UTC
[R] lattice/xyplot: plotting 4 variables in two panels - can this be done?
Try xyplot.zoo in the zoo package (be sure you have the latest zoo version). One caveat is that xyplot.zoo is under development and could change. Here we use the builtin data set anscombe as an example: # display the anscombe data set anscombe library(lattice) library(zoo) # create zoo object using column 1 as x/times and columns 5:8 as the y's z <- zoo(data.matrix(anscombe[,5:8]), anscombe[,1]) xyplot(z, screens = c(1, 1, 2, 2), col = 1:4, pch = 1:4, type = "b") On 8/29/06, S?ren H?jsgaard <Soren.Hojsgaard at agrsci.dk> wrote:> Hi, > I would like to create a plot of y1,y2,y3,y4 against x for several subjects such that y1 and y2 are plotted against x in one panel and y3 and y4 against x in another panel. Thus if there are 3 subjects I should end up with 6 panels. Is there a simple way of doing so (i.e. without calling xyplot() several times, and then padding the results together)?? > Regards > S?ren > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
Possibly Parallel Threads
- xyplot: Plotting two variables, one as points - the other as line. Can that be done without explicitly using panel functions
- Fwd: How to sample from a linear mixed model
- update() ignores object
- Calling substitute(expr, list(a=1)) when expr <- expression(a+b+c)
- Drawing a graph with vertices and edges using tcl/tk