I hope I have not overlooked an answer to this question: I want to make with ggplot a histogramm of only a fraction of the total data. Here's my example:
df<-iris
ggplot(data=df, aes(x=Sepal.Length, y=..density..*100)) +
geom_bar(binwidth=0.1) +
ylab("percent")
This gives a histogramm of all lines.
Now I want to limit the data passed to the plot (for instance) to a Petal.Width of 0.2. Thus the histogram I wish for, only represents the ratio "count Petal.Width=0.2 divided by total count".
Thanks for helping a ggplot-rookie!! With base plot I managed to work around, but I failed here..