I have a scatter plot:
ex<- ggplot(rdr, aes(x = hb, y = iv, color = pt))+ geom_point() +
ylim(-20,20) +
xlim(-20,20) +
annotate(geom = "rect", xmin = -10, xmax = 10, ymin = -10, ymax = 10,
fill = "gray100", colour = "black", alpha = 0.5) +
annotate( geom = "rect", xmin = -10, xmax = 10, ymin = -15, ymax = -10, fill = "palegreen", color = "blue", alpha =0.5)
I want to count how many points are in each of the rectangles. And depending on the color of the point, I want to give them values. ex: blue(0), green(1).
How can I do this?