Contents

1 shape
2 boxplot + scatter
3 boxplot + errorbar + label
4 boxplot + point
5 pirateplot


1 shape #

library(rgr)
shape(iris$Sepal.Length, ifqs = TRUE)
shape.png

2 boxplot + scatter #

--http://www.ats.ucla.edu/stat/r/dae/ologit.htm
dat <- read.dta("http://www.ats.ucla.edu/stat/data/ologit.dta")
ggplot(dat, aes(x = apply, y = gpa)) +
  geom_boxplot(size = .75) +
  geom_jitter(alpha = .5) +
  facet_grid(pared ~ public, margins = TRUE) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))

3 boxplot + errorbar + label #

library(MKmisc)
rb <- qboxplot(Sepal.Length ~ Species, data=iris, col="bisque")
title("Comparing boxplot()s and non-robust mean +/- SD")
mn.t <- tapply(iris$Sepal.Length, iris$Species, mean)
sd.t <- tapply(iris$Sepal.Length, iris$Species, sd)
xi <- 0.3 + seq(rb$n)
points(xi, mn.t, col = "orange", pch = 18)
arrows(xi, mn.t - sd.t, xi, mn.t + sd.t, code = 3, col = "pink", angle = 75, length = .1)
for(i in 1:length(rb$names)){
    #text(i, rb$stats[,i], labels=rb$stats[,i], cex=0.7, pos=3)
    text(i, rb$stats[2:4,i], labels=rb$stats[2:4,i], cex=0.7, pos=3)
}
boxplot_errorbar.png

4 boxplot + point #

source("https://bioconductor.org/biocLite.R")
biocLite("genefu")
library(genefu)

dd <- list("G1"=iris[iris$Species =="setosa", 1], 
           "G2"=iris[iris$Species =="versicolor", 1], 
           "G3"=iris[iris$Species =="virginica", 1])
boxplotplus2(x=dd)
boxplotplus2.png

install.packages("LSD")
library(LSD)
dd <- list("G1"=iris[iris$Species =="setosa", 1], 
           "G2"=iris[iris$Species =="versicolor", 1], 
           "G3"=iris[iris$Species =="virginica", 1])

linesplot(dd,alpha=25,border="darkred",addboxes = TRUE,outline=FALSE)
linesplot.png


5 pirateplot #

http://www.r-bloggers.com/the-pirate-plot-2-0-the-rdi-plotting-choice-of-r-pirates/

Make sure you have installed JAGS-4.x.y.exe (for any x >=0, y>=0) from
http://www.sourceforge.net/projects/mcmc-jags/files
install.packages("devtools")
library("devtools")

install_github("ndphillips/yarrr")
library("yarrr")
#http://www.sourceforge.net/projects/mcmc-jags/files

par(mfrow=c(2,2))

pirateplot(formula = age ~ favorite.pirate,
           data = pirates,
           xlab = "Favorite Pirate",
           ylab = "Age",
           main = "My First Pirate Plot!")



pirateplot(formula = age ~ favorite.pirate,
           data = pirates,
           xlab = "Favorite Pirate",
           ylab = "Age",
           main = "Black and White Pirate Plot",
           pal = "black",
           hdi.o = .7,
           line.o = 1,
           bar.o = .1,
           bean.o = .1,
           point.o = .1,
           point.pch = 16,
           back.col = gray(.97))

pirateplot(formula = age ~ favorite.pirate,
           data = pirates,
           xlab = "Favorite Pirate",
           ylab = "Age",
           main = "Black and White Pirate Plot",
           pal = "black",
           hdi.o = 0,
           line.o = 0,
           bar.o = 1,
           bean.o = 0,
           point.o = 0)

pirateplot(formula = beard.length ~ sex + college,
           data = pirates,
           main = "Beard lengths",
           pal = "southpark",
           xlab = "",
           ylab = "Beard Length",
           point.pch = 16,
           point.o = .2,
           hdi.o = .6,
           bar.o = .1,
           line.o = .5)

par(mfrow=c(1,1))
pirateplot.png