Loading library

library(plotfunctions)

Function add_bars

Add bars to a graph. See example Function errorBars.

Function check_normaldist

par(mfrow=c(1,2))
set.seed(123)

# PLOT1: t-distribution:
test <- rt(1000, df=5)
check_normaldist(test)

# PLOT2: skewed data, e.g., reaction times:
test <- exp(rnorm(1000, mean=.500, sd=.25))
check_normaldist(test)

The ideal normal distribution is displayed in gray, whereas the data is represented by the red line. Generally the distribution is checked by a QQ norm plot, and the function check_normaldist may facilitate interpretation.

par(mfrow=c(1,2))
set.seed(123)

# PLOT1: t-distribution:
test <- rt(1000, df=5)
qqnorm(test)
qqline(test)

# PLOT2: skewed data, e.g., reaction times:
test <- exp(rnorm(1000, mean=.500, sd=.25))
qqnorm(test)
qqline(test)

Function dotplot_error

Creating dotplots with error bars, and optionally grouping of the data points.

# example InsectSprays from R datasets
avg <- aggregate(count ~ spray, data=InsectSprays, mean)
avg <- merge(avg, 
    aggregate(count ~ spray, data=InsectSprays, sd),
    by="spray", all=TRUE)
# we could add the type of spray to the averages:
avg$type <- c(1,1,2,2,2,1)

# visualize output
dotplot_error(avg$count.x, se.val=avg$count.y, groups=avg$type, labels=avg$spray)