Re: [R] Histogram omitting/collapsing groups

2012-01-01 Thread Aren Cambre
Thanks. That did it! And I get it now--in your original example, aes(x = x, y = Freq), x refers to the column name in as.data.frame(table(x)), not the x vector(?) you created. Aren On Sun, Jan 1, 2012 at 4:44 PM, Joshua Wiley wrote: > Sorry, that was probably a really confusing example...too ma

Re: [R] Histogram omitting/collapsing groups

2012-01-01 Thread Joshua Wiley
Sorry, that was probably a really confusing example...too many xs floating around. set.seed(10) rawdata <- sample(0:23, 1, TRUE, prob = sin(0:23)+1) ## do theis step first for your data tableddata <- as.data.frame(table(rawdata)) ## use these names in ggplot colnames(tableddata) require(ggpl

Re: [R] Histogram omitting/collapsing groups

2012-01-01 Thread Aren Cambre
This is helpful, although I can't seem to adapt it to my own data. If I run your sample as is, I do get the nice graphs. However, this doesn't work: (Assume you already have a data frame "dallas" with 2057980 rows. It has column "offense_hour", and each row has a value between 0 and 23, inclusive

Re: [R] Histogram omitting/collapsing groups

2012-01-01 Thread Joshua Wiley
Hi Aren, I was busy thinking about how to make what you wanted, and I missed that you were working with hours from a day. That being the case, you may think about a circular graph. The attached plots show two different ways of working with the same data. Cheers, Josh set.seed(10) x <- sample(

Re: [R] Histogram omitting/collapsing groups

2012-01-01 Thread Aren Cambre
On Sun, Jan 1, 2012 at 5:29 AM, peter dalgaard wrote: > Exactly. If what you want is a barplot, make a barplot; histograms are for > continuous data.   Just remember that you may need to set the levels > explicitly in case of empty groups: barplot(table(factor(x,levels=0:23))). > (This is irrel

Re: [R] Histogram omitting/collapsing groups

2012-01-01 Thread peter dalgaard
On Jan 1, 2012, at 07:40 , Joshua Wiley wrote: > If you just want a plot of the frequencies at each hour why not just call > barplot on the output of table? Histograms create bins and count in those, > which doesn't sound like what you're after. > Exactly. If what you want is a barplot, make

Re: [R] Histogram omitting/collapsing groups

2011-12-31 Thread Joshua Wiley
If you just want a plot of the frequencies at each hour why not just call barplot on the output of table? Histograms create bins and count in those, which doesn't sound like what you're after. Cheers, Josh On Dec 31, 2011, at 21:37, jim holtman wrote: > Fast fingers; notice that there is s

Re: [R] Histogram omitting/collapsing groups

2011-12-31 Thread jim holtman
Fast fingers; notice that there is still a problem in the counts; I was only looking at the last. Happy New Year -- up too late. On Sun, Jan 1, 2012 at 12:33 AM, jim holtman wrote: > Here is a test I ran and looks fine, but then I created the data, so > it might have something to do with your d

Re: [R] Histogram omitting/collapsing groups

2011-12-31 Thread jim holtman
Here is a test I ran and looks fine, but then I created the data, so it might have something to do with your data: > x <- sample(0:23, 10, TRUE) > a <- hist(x, breaks = 24) > a[1:5] $breaks [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 $counts [1] 8262 4114 418

Re: [R] Histogram omitting/collapsing groups

2011-12-31 Thread Sarah Goslee
Hi, I think you're not understanding quite what's going on with hist. Reread the help, and take a look at this small example. The solution I'd use is the last item. > x <- rep(1:10, times=1:10) > table(x) x 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 > > > hist(x, plot=FALSE, righ

[R] Histogram omitting/collapsing groups

2011-12-31 Thread Aren Cambre
I have two large datasets (156K and 2.06M records). Each row has the hour that an event happened, represented by an integer from 0 to 23. R's histogram is combining some data. Here's the command I ran to get the histogram: > histinfo <- hist(crashes$hour, right=FALSE) Here's histinfo: > histinfo