Percentage Display in R / GGPLOT2

I have a basic graph of a data frame of two columns (x = "Periods" and y = "Range").

enter image description here

library (ggplot2)
qplot (Periods, Range, data=twocoltest, color=Periods, size = 3,) + geom_jitter(position=position_jitter(width=0.2))

I am trying to add a horizontal line to each period, below which lies 90% of all observations for this period. (It should not be a horizontal line, any visual indication for the period will be sufficient).

Any help would be greatly appreciated.

+5
source share
1 answer

Ok, I read ggplot help, and here go:

# example data 
twocoltest <- data.frame(Periods=rep(1:3,each=3),Range=1:9)

library(ggplot2)
c <- qplot (Periods, Range, data=twocoltest, color=Periods, size = 3,) + geom_jitter(position=position_jitter(width=0.2))
q90 <- function(x) {quantile(x,probs=0.9)}

c + stat_summary(fun.y=q90, colour="red", geom="crossbar", size = 1, ymin=0, ymax=0) 

enter image description here

+5
source

All Articles