tags:

views:

88

answers:

1

I have a pre-binned frequency table for a rather large dataset. That is, a single column vector of bins and a single column vector of counts associated with those bins. I'd like R to plot a histogram of this data by doing further binning and summing the existing counts. For example, if in the pre-binned data I have something like [(0.01, 5000), (0.02, 231), (0.03, 948)], where the first number is the bin and the second is the count, and I choose 0.04 as the new bin width, I'd expect to get [(0.04, 6179)]. What's the fastest and or easiest way to do this in R?

+1  A: 

Looks like ggplot2 has the answer.

 
library(ggplot2)
qplot(bin, data=cbind(bins,counts), weight=counts, geom="histogram")
Jacob
you're fast ;) I was just looking up how I did this in the past. I saw two ways I had hacked around this 1) ggplot2 and 2) sampling from the binned data and then rebinning. I much preferred ggplot2 but the rebinning was a hack I cooked up prior to discovering ggplot could do this.
JD Long