r - Confidence intervals for ggplot -


if have 2 sets of data want plot on same graph, there way confidence intervals 1 of datasets , not other? e.g., regressions show significant data group not b, still want visually depict data both & b in same graph, confidence intervals around significant group only.

you can selectively choose data pass regression plotter.

consider example:

set.seed(10)  #make sample data df <- data.frame(   group=rep(c("a","b"), each=10),   x = rep(1:10, 2)) df$y <- 2*df$x + runif(20, -20, 20)  #create y values lots of noise  #reduce noise group df[df$group == "a", "y"] <- 2*df[df$group == "a", "x"] + rnorm(10)  #compare regression p-values coef(summary(lm(y ~ x, data=df[df$group == "a", ])))[, 4] #p < 0.05 group # (intercept)            x  #1.577943e-01 5.411004e-09   coef(summary(lm(y ~ x, data=df[df$group == "b", ])))[, 4] #p > 0.05 group b #(intercept)           x  #  0.7338232   0.1309030  #graph points, coloring group.  add regression line group only. ggplot(df, aes(x=x, y=y, colour= group)) + theme_bw() +     geom_point(size=2.5) +     geom_smooth(data = df[df$group == "a",], method="lm") 

regression group only


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -