I have a data frame like this:
CWSR = c(0.2, 0.1, 0.5, 0.6, 0.4, 0.8, 0.9, 0.7, 0.1, 0.2) 
BPA = c(1,5,9,8,4,3,2,1,4,3) 
df = data.frame(CWSR, BPA)
   CWSR BPA
1   0.2   1
2   0.1   1
3   0.5   9
4   0.1   2
5   0.4   4
6   0.1   2
7   0.9   2
8   0.1   3
9   0.1   2
10  0.2   3
I have generated the below histogram but instead of the layout produced, I want to display show a dot for each value in my graph, rather than an entire bar. Currently I am using this:
p <- ggplot(HData, aes(BPA, CWSR))
p + geom_bar(stat="identity")

In addition, I am looking to count the number of instances of BPA IF the value of CWSR is equal to 0.1, then to display this as a percentage.
So in the example above, for BPA value of 1, this occurs once for the value of CWSR 0.1 (line 2) so this would show 100%. For the BPA value of 2, this occurs 3 times for the value of CWSR 0.1 (lines 4,6,9) BUT there is a BPA value of 2 and CWSR value not equal to 1 (line 7, 0.9) so the total percentage would show as 75% (3 out of 4).
I have tried something like this:
df %>%
  group_by(BPA) %>% 
  summarise(num = n(),
            totalCWSR = sum(CWSR==1), totalP = (totalCWSR / num * 100)) 
But not sure if it is correct or how to display in ggplot?
I hope this is clearer, apologies for not providing as much detail previously.
 
    
 
    
