all!
I have managed to produce a plot like below using ggplot2 which have the total number of points in each group. If I want to add the number of points greater or lower than 0 separately, how can that be done?
Thank you!!!
give.n <- function(x){
return(c(y = 10, label = length(x)))
}
ggplot(dta, aes(x=type, y=foldChange, fill=grp)) +
geom_point(size=1,alpha=0.2,position = position_jitterdodge(jitter.width = .2),aes(col=grp)) +
geom_boxplot(alpha=0,outlier.shape=NA) + guides(fill=FALSE) + theme_bw() + xlab("") +
geom_hline(yintercept = 0,col="red") +
stat_summary(fun.data = give.n, geom = "text", fun.y = median, position = position_dodge(width = 0.75))
You can subset inside ggplot functions in order to plot whatever you want. In your case it would look like this if you wanted values > 0
I'm not sure what you mean exactly by adding the points later, but this should at least filter the points you desire.