[This article was first published on Sustainable Research » Renglish, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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,res\$conf.int,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 their blog: Sustainable Research » Renglish.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

# Never miss an update! Subscribe to R-bloggers to receive e-mails with the latest R posts.(You will not see this message again.)

Click here to close (This popup will not appear again)