setwd("M:/web/17C - 2018/scripts")
library(tidyverse)
wasp <- read.table("../data/wasp.txt", header = T)
str(wasp)
# $ time : int 22 33 14 24 26 18 17 12 35 27 ...
ggplot(data = wasp, aes(x = status, y = time)) + geom_violin()
waspsummary <- wasp %>% group_by(status) %>% summarise(mean = mean(time), std = sd(time), n = length(time), se = std/sqrt(n))
t.test(data = wasp, time ~ status, var.equal = T)
wasp <- merge(wasp, waspsummary[,1:2], by = "status")
wasp <- wasp %>% mutate(residual = time - mean)
shapiro.test(wasp$residual)
ggplot(data = wasp, aes(x = mean, y = residual)) + geom_point()
ggplot() + geom_point(data = wasp, aes(x = status, y = time), position = position_jitter(width = 0.1, height = 0), colour = "gray50") + geom_errorbar(data = waspsummary, aes(x = status, ymin = mean - se, ymax = mean + se), width = 0.3) + geom_errorbar(data = waspsummary, aes(x = status, ymin = mean, ymax = mean), width = 0.2) + ylab("Time (hr)") + xlab(NULL) + ylim(0, 70) + scale_x_discrete(labels = c("Mated", "Unmated")) + theme_classic()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.