Skip to content

Instantly share code, notes, and snippets.

@helenaeitel
Created November 12, 2016 19:26
Show Gist options
  • Save helenaeitel/3e48cf3f2d635c6172bcda545680c27d to your computer and use it in GitHub Desktop.
Save helenaeitel/3e48cf3f2d635c6172bcda545680c27d to your computer and use it in GitHub Desktop.
#Helena Eitel and Perri Haser
#Bio Lab 6, Section Monday 1:30pm
#TA: Xintao Fan
#11.12.16
library(readr)
library(dplyr)
library(ggplot2)
library(RColorBrewer)
#PERFORM T-TEST
a <- read_csv('./Lab6distances.csv')
#Change the name of the length column
names(a)[3] <- 'Length'
b <- as.data.frame(a)
attach(b)
#perform a Welch Two Sample t-test
stats <- t.test(b[Treatment=='Control',3],b[Treatment=='Osmotic',3])
#Welch Two Sample t-test
#t = -0.068022, df = 46.782, p-value = 0.9461
#alternative hypothesis: true difference in means is not equal to 0
#95 percent confidence interval:
# -0.6419379 0.5999518
#sample estimates:
# mean of x mean of y
#2.468293 2.489286
#CREATE BARGRAPH
#create standard error function
se <- function(x) sqrt(var(x)/length(x))
#aggregate data and create mean and standard error variables
data <- b %>% group_by(Treatment) %>% summarise(MEAN=mean(Length),SE=se(Length))
#plot mean distance with standard error bars
plot <- ggplot(data, aes(x = Treatment, y = MEAN)) +
geom_bar(stat = "identity") +
geom_errorbar(aes(ymin = MEAN - SE, ymax = MEAN + SE), width=.2) +
theme_classic(base_size=25) +
scale_y_continuous(breaks=c(0,0.5,1,1.5,2,2.5,3)) +
labs(y='Mean Distance\nbetween Nuclei (micrometers)')
#save image as a png
png('Bio12Lab6.png',width=500,height=400)
print(plot)
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment