Hi. I want to plot per vs the frequency of per; I want to count the frequencies, but I want to combine the binwidths of the per's. geom_bar does not support binwidth. What do you suggest? Thank you.
library(ggplot2)
t <- c(0,5,2,5,1,2,0,0,0,1,0,1,1,3)
c <- c(10,16,16,16,10,20,20,20,21,18,6,6,6,22)
per <- t/c
df <- data.frame(cbind(t,c,per))
As it stands the graph gives me every value of per on the horizontal axis. I would like to combine say 1 <= per <1.05, 1.051 <= per <1.10, etc. I thought binwidth was the command for this.
geom_bar() doesn't has a binwidth argument because it doesn't calculate bins like geom_histogram() but it has the width argument that I think you can use for what you are trying to do (if I'm understanding you correctly).
library(ggplot2)
t <- c(0,5,2,5,1,2,0,0,0,1,0,1,1,3)
c <- c(10,16,16,16,10,20,20,20,21,18,6,6,6,22)
per <- t/c
df <- data.frame(cbind(t,c,per))
ggplot(data = df, aes(x = per)) +
geom_bar(stat="count", width=.05) +
xlab(seq(0,1,.1)) +
labs(title = "Frequency", x = "Percent Matches", y = "Frequency")
If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it: