[R] Lattice question.
    Rolf Turner 
    r.turner at auckland.ac.nz
       
    Mon Mar 30 02:26:22 CEST 2009
    
    
  
Thanks very much for your input.
On 30/03/2009, at 12:29 PM, Felix Andrews wrote:
> Modifying your example...
>
>
> library(lattice)
> set.seed(42)
> XX <- data.frame(y=runif(300,0,10),a=factor(sample(letters[1:3],300,
>                                            TRUE,c(0.5,0.3,0.2))))
> XX <- rbind(XX,XX)
> XX$gps <- rep(c("count","percent"),each=300)
> print(histogram(~y|a*gps,as.table=TRUE,data=XX,
> panel=function(x,...,type) {
>                panel.histogram(x,...,type=c("count","percent") 
> [current.row()])
>        }
> ))
>
>
> but the use of current.row() breaks if the layout changes.
	I kind of get the feeling that doing what I want will require
	constant ad hoc adjustment, so this is not really a worry.
> Also, the y scales are the same here for count and percent data, which
> may not be appropriate.
	Indeed.  The thought had crossed my mind ....
> You may have to set the y scales for each panel explicitly.
	Yes, I'd like to ... but I can't figure out how.  I tried
	a bit of an experiment and got the impression that
	panel.histogram() did not respond to specifications of ylim.
	I may just have done something silly ....
> Or, another option is:
>
> a <- histogram(~y|a, data = XX, subset = gps=="count", type="count")
> b <- histogram(~y|a, data = XX, subset = gps=="density",  
> type="density")
> library(latticeExtra)
> update(c(count=a, density=b), layout=c(3,2), ylab=c("count",  
> "density"))
	That looks very interesting; I'll give it a try.
	Thanks.
		cheers,
			Rolf
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
    
    
More information about the R-help
mailing list