I am trying to plot a histogram using ggplot2 with percentage on the y-axis and numerical values on the x-axis.
A sample of my data and script looks like this (below) and goes on for about 100,000 rows (or more).
A B
0.2 x
1 y
0.995 x
0.5 x
0.5 x
0.2 y
ggplot(data, aes(A, colour=B)) + geom_bar() +stat_bin(breaks=seq(0,1, by=0.05)) + scale_y_continuous(labels = percent)
I want to know the percentage of B values distributed in each bin of A value, instead of the number of B values per A value.
The code as it is now gives me a y-axis with ymax as 15000. The y-axis is supposed to be in percentages (0-100).
