[R] lattice histogram for multiple variables : adjusting x axis

GOUACHE David D.GOUACHE at arvalisinstitutduvegetal.fr
Tue May 12 10:29:24 CEST 2009


Hello all,

I have a large data frame and I want to look at the distribution of each variable very quickly by plotting an individual histogram for each variable.
I'd like to do so using lattice.

Here is a small example using the iris data set:

histogram(as.formula(paste("~",paste(colnames(iris[,!sapply(iris,is.factor)]),collapse="+"))),data=iris[,!sapply(iris,is.factor)])

However in this graphic, the x-axis and the breaks are the same for all 4 variables. I would like them to be adjusted to the data in each panel separately. I have tried using the scales argument to no avail:

histogram( as.formula(paste("~",paste(colnames(iris[,!sapply(iris,is.factor)]),collapse="+"))) ,data=iris[,!sapply(iris,is.factor)], scales=list(x=list(relation="free")) )


How can I individualize the x-axis and breaks for each individual panel?

Thanks for any help.

David Gouache
ARVALIS - Institut du végétal
Station de La Minière
78280 Guyancourt
Tel: 01.30.12.96.22 / Port: 06.86.08.94.32




More information about the R-help mailing list