[R] Loop for multiple plots in figure
Marcel Curlin
cemarcel at u.washington.edu
Mon Jun 25 08:06:19 CEST 2012
Hello, I have longitudinal data of the form below from N subjects; I am
trying to create figure with N small subplots on a single page, in which
each plot is from only one subject, and in each plot there is a separate
curve for each value of param1.
So in this case, there would be four plots on the page (one each for Bob,
Steve, Kevin and Dave), and each plot would have two separate curves (one
for param1 = 1 and one for param1 = 0). The main title of the plot should be
the subject name. I also need to sort the order of the plots on the page by
param2.
I can do this with a small number of subjects using manual commands. For a
larger number I know that a 'for loop' is called for, but can't figure out
how to get each of the subjects to plot separately, could not figure it out
from the existing posts. For now I want to do this in the basic environment
though I know that lattice could also work (might try that later). Any help
appreciated
tC <- textConnection("
Subject Xvar Yvar param1 param2
bob 9 100 1 100
bob 0 250 1 200
steve 2 454 1 50
bob -5 271 0 35
bob 3 10 0 74
steve 1 500 1 365
kevin 5 490 1 546
bob 8 855 0 76
dave 2 233 0 343
steve -10 388 0 556
steve -7 284 1 388
dave 3 568 1 555
kevin 4 247 0 57
bob 6 300 1 600
")
data <- read.table(header=TRUE, tC)
close.connection(tC)
rm(tC)
par(mfrow=c(2,2)
--
View this message in context: http://r.789695.n4.nabble.com/Loop-for-multiple-plots-in-figure-tp4634390.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list