I have the following data:
set.seed(1)
df <- data.frame(ID = c(1:123),
value = rnorm(123, mean = 30))
and I prepare the plot
ggplot (df) +
geom_rect(aes(xmin = 0, xmax = 100, ymin = 28.4, ymax =31.6),
fill = "lightcoral", alpha = 0.006) +
geom_point(aes(x=ID, y = value), color = "red3")
How to determine (calculate) y min and y max so that 80% of the points are in the middle of the area? Of course, an area may contain 98 points (in this example).