(This article was first published on

**Sustainable Research » Renglish**, and kindly contributed to R-bloggers)Sometimes when working with small paired data-sets it is nice to see/show all the data in a structured form. For example when looking at pre-post comparisons, connected dots are a natural way to visualize which data-points belong together. In R this can be easily be combined with boxplots expressing the overall distribution of the data. This also has the advantage of beeing more true to non-normal data that is not correctly represented by means +/- 95%CI. I have not come up against a good tutorial of how to do such a plot (although the right hand plot borrows heavily from this post on the excellent R-mailing list), so in the post you will find the code to generate such a graph in R.

Here comes the code (Update 05.12.2011 without umlauts):

^{?}View Code RSPLUS

#generatingsomedata pre<-55+rnorm(20) post<-pre+0.7+rnorm(20) #Settinguptwoscreens par(mfrow=c(1,2)) #FirstGraph s<-seq(length(pre)) par(bty="l") boxplot(pre,post,main="Rawdata",xlab="Time",ylab="Measure",names=c("pre","post"),col=c("lightblue","lightgreen")) stripchart(list(pre,post),vertical=T,pch=16,method="jitter",cex=0.5,add=T) segments(rep(0.95,length(pre))[s],pre[s],rep(2,length(pre))[s],post[s],col=1,lwd=0.5) #Secondgraph #Confidenceintervals eitherparametric (t.test) or non-parametric (wilcox.text) #res<-t.test(post,prä,paired=T,conf.int=T) res<-wilcox.test(post,pre,paired=T,conf.int=T) stripchart(post-pre,vertical=T,pch=16,method="jitter",main="Difference",ylab="Difference:Post–Prä",xlab="Median+/-95%CI") points(1,res$estimate,col="red",pch=16,cex=2) arrows(1,res$conf.int[1],1,res$conf.int[2],col="red",code=3,lwd=3,angle=90) abline(h=0,lty=2)#Zero-effectline |

To

**leave a comment**for the author, please follow the link and comment on his blog:**Sustainable Research » Renglish**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...