Re: [R] ggplot2: stat_bin ..count.. with geom_text when NA is present

2009-10-28 Thread Bryan Hanson
Hadley, thanks - that was a permutation that I did not try (but should have thought of it). But... Now, when some observations are removed, you get the count on the plot (previously one did not), however, alas, a new problem: the value of .count.. includes the NA's or something similar. Revised

Re: [R] ggplot2: stat_bin ..count.. with geom_text when NA is present

2009-10-28 Thread hadley wickham
Hi Bryan, Thanks for the reproducible example. The problem is actually in your code, not mine ;) You probably want: y = min(res, na.rm = TRUE) - 0.1 * diff(range(res, na.rm = TRUE)) Hadley (drop = TRUE solves a difference problem - it controls whether or not to remove bins with zero count) On

Re: [R] ggplot2: stat_bin ..count.. with geom_text when NA is present

2009-10-23 Thread Bryan Hanson
.. Adding to my original post... OK, here's a little function which demonstrates the behavior I described. Try it with rem = FALSE to see the annotation, then TRUE to see the annotations disappear. What's going on here? Thanks, Bryan res = runif(50, 0, 100) fac = rep(c("A", "B"), 50) df <- data.

[R] ggplot2: stat_bin ..count.. with geom_text when NA is present

2009-10-23 Thread Bryan Hanson
One for the ggplot2 gurus... I have a function which makes a plot just fine if the response vector (res in the example; fac1 is a factor) has no NA in it. It plots the data, then makes a little annotation at the bottom with the data counts using: p <- p + geom_text(aes(x = fac1, y = min(res)