Wednesday, 15 May 2013

r - Plotting multiple histograms in same panel -



r - Plotting multiple histograms in same panel -

i trying plot multiple histograms of variables in info frame in same panel. here next code:

library(lattice) dd <- data.frame(gp = factor(rep(paste('group', 1:6, sep = ''), each = 100)), x = rnorm(600)) histogram( ~ x | gp, info = dd) histogram( ~ x | gp, info = dd, as.table = true)

this putting info x groups 1 6. in given dataframe, have numbers in particular categories. example, suppose want plot histogram of height, weight , average blood pressure level (variables in date frame) in same panel. how without having form new info set , groups 1 3?

no need reshape info here.

histogram( ~ height +age +weight ,data = dd)

you can ply layout alter display order of panels. example:

histogram( ~ height +age +weight ,layout=c(1,3),data = dd)

this produce 3 histograms in 3 panels.

edit

to add together title can utilize main

histogram( ~ height +age +weight ,layout=c(1,3),data = dd, main='please read lattice help')

side note: settings parameters shared between different lattice functions. illustration entry of xlab: see xyplot. when go xyplot help can read :

main: typically character string or look describing main title placed on top of each page. defaults null

r lattice

No comments:

Post a Comment