[R] lattice histogram finetuning

Jacques VESLOT jacques.veslot at cirad.fr
Tue Jan 31 11:51:53 CET 2006


it looks like a barchart rather than an histogram (?).
if it is, you can do something like that:

CT.flow$age <- factor(CT.flow$age)
CT.flow$succession <- 
factor(CT.flow$succession,levels=c("early","mid","late"))

ct <- expand.grid(  succession=levels(CT.flow$succession),
                    site=levels(CT.flow$site),
                    age=levels(CT.flow$age)

ct$eff <- as.vector(ftable(xtabs(~.,CT.flow)))

barchart(eff~age|site*succession,horiz=F,ct)



Patrick Kuss a écrit :

>Dear list,
>
>I have some difficulties fine-tuning a lattice conditional histogram plot and
>found little help in the documentation.
>My dataset consists of plant flowering ages from 3 different altitudes and 3
>successional sites at each altitudinal level.
>
>My questions are:
>
>How do I avoid that lattice automatically sorts the different $condlevels
>alphabetically? I need:
>hist$condlevels$succession <- list("early","mid","late")
> # not "early","late","mid"
>hist$condlevels$site <- list("FU","SP","JU")
>
>Additionally, how do I add a vertical line indicating the mean flowering age at
>each panel?
>
>And how do I assure breaks to happen for each year?
>hist$panel.args.common$breaks
>
>
>Happy for any suggestions
>
>Patrick
>
>
># Flowering age at different altitudes and successional site
>
>FU.e <- round(rnorm(20,mean=9,sd=1),dig=0)
>FU.m <- round(rnorm(20,mean=12,sd=1),dig=0)
>FU.l <- round(rnorm(20,mean=15,sd=1),dig=0)
>SP.e <- round(rnorm(20,mean=8,sd=1),dig=0)
>SP.m <- round(rnorm(20,mean=11,sd=1),dig=0)
>SP.l <- round(rnorm(20,mean=14,sd=1),dig=0)
>JU.e <- round(rnorm(20,mean=7,sd=1),dig=0)
>JU.m <- round(rnorm(20,mean=10,sd=1),dig=0)
>JU.l <- round(rnorm(20,mean=13,sd=1),dig=0)
>
>age <- c(FU.e,FU.m,FU.l,SP.e,SP.m,SP.l,JU.e,JU.m,JU.l)
>site <- rep(c("FU","SP","JU"),each=60)
>succession <- rep(c("early","mid","late"),each=20,times=3)
>
>CT.flow <- data.frame(site,succession,age)
>
>library(lattice)
>trellis.device(color=F)
>
>hist <- histogram(~age|succession*site,data=CT.flow)
>hist
>
>
>
>--
>Patrick Kuss
>PhD-student
>Institute of Botany
>University of Basel
>Schönbeinstr. 6
>CH-4056 Basel
>+41 61 267 2976
>
>______________________________________________
>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
>
>  
>




More information about the R-help mailing list