Skip to content
Prev 350629 / 398502 Next

Question about paired plotting

Hi Luis,
Ah yes, that paper.  I was rather shocked at what it implied :(  People are still using dynamite plots, for heaven's sake! See http://biostat.mc.vanderbilt.edu/wiki/Main/DynamitePlots  for some comments.
I see Jim has given you one way to do the plots you want. Here is another way using the ggplot2 package. You will probably have to install the package.  The code below covers the 2B:2D plots.
####=======Install ggplot2===================
install.packages("ggplot2")

###======== plot desired graphs==================
library(ggplot2)

dat1  <-  data.frame(x1  = rep("A", 4) , x2  =  rep("B", 4), y1  =  5:8,  y2  = 10:13)

p  <-  ggplot() 
p1  <-   p +  geom_segment( aes(x = x1, y = y1, xend =  x2,  yend = y2)) +
          geom_point(aes(x1, y1, colour = "blue", size = 2)) +
          geom_point(aes(x2, y2, colour = "red", size = 2)) 
p1
      
 p2  <-     p1 +     theme (legend.position = "none") + 
                  xlab("Treatment") + ylab("Change Score")
p2

###======== end==================

We could have all the commands in one statement but it is easier to write the code this way to help in debugging (damn typos1) and so I left it to help you see what is happening.

For the lower plots, in ggplot2, you should have a look at geom_dotplot() . Here is an interesting demo of it in use.  I like the addition of the median line in particular.  

http://rstudio-pubs-static.s3.amazonaws.com/1406_947a49f2d7914dad8b0fd050a9df9858.html




John Kane
Kingston ON Canada
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!