ahimsa campos-arceiz <ahimsa <at> camposarceiz.com> writes: > > Hi, > > I'm plotting a multiple histogram using the function multhist {package > plotrix}, something like: > > library(plotrix) > mh <- list(rnorm(200, mean=200, sd=50), rnorm(200, mean=250, sd=50)) > multhist(mh) > > In this graph y-axis represents the frequency of observations.... but I > would like it to be scaled into relative frequencies, > > does anybody know how to do this with multhist or similar function? > > thanks a lot, > > Ahimsa >
In its current form, multhist doesn't allow the freq=FALSE or prob=TRUE arguments to be passed to hist() (the ... argument passes optional arguments to barplot, not hist). You could hack it as follows: pmulthist <- function (x, breaks = "Sturges", ...) { allhist <- hist(unlist(x), breaks = breaks, plot = FALSE, freq=FALSE) combhist <- t(sapply(x, function(z) hist(z, breaks = allhist$breaks, plot = FALSE)$counts)) barplot(combhist, beside = TRUE, names = signif(allhist$mids, 2), ...) } ______________________________________________ R-help@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 and provide commented, minimal, self-contained, reproducible code.