From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>

Date: Mon, 11 Feb 2008 14:46:41 -0800

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. Received on Mon 11 Feb 2008 - 22:53:48 GMT

Date: Mon, 11 Feb 2008 14:46:41 -0800

On 2/11/08, willem vervoort <willemvervoort_at_gmail.com> wrote:

> Dear R-help list,

*>
**> I am trying to construct a lattice histogram using 3 factors.
**>
**> My dataframe looks like this: (simulating a waterbalance over
**> groundwater with different salinities)
**>
**> s days model EC EC_max
**> 0.4 1 "A" 10 9
**> 0.42 2 "A" 10 9
**> 0.44 3 "A" 10 9
**> : : : : :
**> 0.4 1 "B" 10 9
**> : : : : :
**> 0.4 1 "A" 30 9
**> : : : : :
**> 0.4 1 "A" 30 36
**>
**> Anyway you get the gist
**> EC_max has two levels 9 and 36, EC has 3 levels 10, 30 and 70, and
**> model has two levels ("A" and "B"). There are say 365 days and s is
**> the variable of interest (soil saturation)
**>
**> Can maybe be reproduced with:
**> data <- data.frame(s = rnorm(2*3*365*2),rep(1:365,12), model =
**> sort(rep(c("A","B"),6*365)),
**> EC = rep(sort(rep(c(10,30,70),365*2)),2), EC_max =
**> rep(sort(rep(c(9,36),3*365)),2))
**>
**> I would like to plot histograms with the three factors using Lattice
**> so I had the following code:
**>
**> my.strip <- function(which.given, ..., factor.levels) {
**> levs <- if (which.given == 1) c("Model A","Model B")
**> else {if(which.given == 2) paste("EC =
**> ",as.character(EC),"dS/m")
**> else paste("ECmax = ",as.character(EC_max),"dS/m")}
**> strip.default(which.given, ..., factor.levels = levs)
**> }
**>
**> histogram(~s|model*as.factor(EC)*as.factor(EC_max),data=Store,xlab="soil
**> saturation",type="density",strip=my.strip)
**>
**> But I am doing something wrong, because it plots the histogram for
**> factor level EC_max =9 first and than straight over it the histogram
**> for factor level 36, so only 6 panels on the graph rather than 12.
**>
**> I searched the archives, but no luck so far.
*

Look up the 'layout' argument in ?xyplot. By default, for 2 or more conditioning variables, the levels of the first two define columns and rows, and the rest are spread out over multiple pages. In your example, you could try layout = c(6, 2) for starters.

-Deepayan

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. Received on Mon 11 Feb 2008 - 22:53:48 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Tue 12 Feb 2008 - 01:30:12 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*