Skip to content

histogram

3 messages · Felipe, Adaikalavan Ramasamy, Jim Lemon

#
If I understand you correctly, you already pre-computed the frequencies 
and bin widths and want to display them as a histogram. If correct, then 
what you are asking for is analogous to what bxp() is to boxplot. I am 
not sure if such a function exists.

Instead you can think of the task as drawing a bunch of rectangles 
(perhaps using symbols?). Or you can hack the hist() code and try

    br    <- c(0,20,30,40,50,60,70,80,100)
    dens  <- runif( length(br) - 1 )

    r <- structure(list(breaks = br, density = dens),
                   class = "histogram")

    plot(r, main="Felipe's Histogram")

However, I do emphasize that this is a hack. If you have the original 
data that you used to calculate the densities, consider using the breaks 
argument with hist(). It is better to use tried and tested codes.

Regards, Adai
Felipe wrote:
#
Felipe wrote:
Hi Felipe,
Try this:

library(plotrix)
testdat<-sample(1:100,1000,TRUE)
testfac<-cut(testdat,breaks=seq(0,100,by=10))
library(prettyR)
testdensity<-as.vector(freq(testfac,display.na=FALSE)[[1]])
barp(testdensity/1000,names.arg=names(testdensity),staxx=TRUE)

Jim