Hi: Is this what you had in mind?
library(reshape2) df <- df[, -10] # last variable is superfluous dm <- melt(df, id = 'day') head(dm) day variable value 1 1 var1 1 2 2 var1 2 3 3 var1 3 4 4 var1 4 5 1 var2 100 6 2 var2 200 xyplot(value ~ day | variable, data = dm, scales = list(y = list(relation = 'free'))) melt() is useful in this problem because it stacks the data in 'long' form and creates a factor 'variable' whose levels are the variable names. The variable 'value' contains the responses. Conditioning on 'variable' in dm then gets you individual plots of value ~ day by variable. You can use layout = to specify the arrangement of plots per page, and perhaps as.table = TRUE if you want the plots rendered from top left rather than bottom left. HTH, Dennis On Mon, Nov 8, 2010 at 10:19 AM, Marcus Drescher <dresc...@tum.de> wrote: > Dear all, > > I am trying (!!!) to generate pdfs that have 8 plots on one page: > > > df = data.frame( > day = c(1,2,3,4), > var1 = c(1,2,3,4), > var2 = c(100,200,300,4000), > var3 = c(10,20,300,40000), > var4 = c(100000,20000,30000,4000), > var5 = c(10,20,30,40), > var6 = c(0.001,0.002,0.003,0.004), > var7 = c(123,223,123,412), > var8 = c(213,123,234,435), > all = as.factor(c(1,1,1,1))) > > pdf("test1.pdf", width=20, heigh=27, paper="a4") > print(plot(groupedData(var1 ~ day | all, data = df), main = "var1", > xlab="", ylab=""), split=c(1,1,2,4), more=TRUE) > print(plot(groupedData(var2 ~ day | all, data = df), main = "var2", > xlab="", ylab=""), split=c(1,2,2,4), more=TRUE) > print(plot(groupedData(var3 ~ day | all, data = df), main = "var3", > xlab="", ylab=""), split=c(1,3,2,4), more=TRUE) > print(plot(groupedData(var4 ~ day | all, data = df), main = "var4", > xlab="", ylab=""), split=c(1,4,2,4), more=TRUE) > print(plot(groupedData(var5 ~ day | all, data = df), main = "var5", > xlab="", ylab=""), split=c(2,1,2,4), more=TRUE) > print(plot(groupedData(var6 ~ day | all, data = df), main = "var6", > xlab="", ylab=""), split=c(2,2,2,4), more=TRUE) > print(plot(groupedData(var7 ~ day | all, data = df), main = "var7", > xlab="", ylab=""), split=c(2,3,2,4), more=TRUE) > print(plot(groupedData(var8 ~ day | all, data = df), main = "var8", > xlab="", ylab=""), split=c(2,4,2,4)) > dev.off() > > > My problem is that the separate plots all have different sizes. (Some are > tall, but very small, or the other way around. The target is to have equally > tall and wide graphs. (The variables have different scales. Grouping does > not work.) > > Optimally, the plots would use the complete pdf page. > > Any ideas how to adjust height and width? > > Best > Marcus > > ______________________________________________ > 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.