-
Notifications
You must be signed in to change notification settings - Fork 0
/
Oysters.R
146 lines (127 loc) · 5.76 KB
/
Oysters.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#packages: ggplot2, car
# initialHeights1<-c(63,32,48,61,71,41,58,69,33,34,70,61,61,51,39,45,61,60,61,67,60,55,40,69,55,29,60,46,46,53,75,42,21,35,72,61,48,46,47,73,55,31,43,37,52,56,52,40,63,48,50,19,59,59,47,63,41,41,26,35,48,64,44,60,40,49,47,35,55,45,60,42,42,46,49,56,48,45,40,37,60,59,37,28,51,61,45,35,26,54,41,44,58,39,41,47,34,47,50,52,55,43,44,45,41,26,50,38,41,58,42,37,36,48,28,24,32,29,45,70,64,67,24,35,63,56,41,37,47,55,38,75,47,43,40,39,65,50,42,42,40,60,28,36,60,64,48,48,50,49,33,34,40,43,59,46,30,38,58,43,45,35,34,37,48,58,58,42,46,57,44,24,40,40,41,37,59,57,68,40,45,49,50,35,35,30,36,30,32,70,34,41,54,29,43,52,32,37,38,70,42,32,56,37,35,58,50,38,42,43,55,60,43,68,46,60,53,55,59,55,32,50,41,64,37,59,57,52,55,50,38,60,61,37,60,62,55,45,63,47,35,62,61,65,36,62,59,42,39,49,35,50,49,46,43,45,34,44,44,30,41,49,45,41,42,48,32,80,69,69,50,46,57,45,59,63,56,51,45,51)
#
# oysterAvgInitial<-mean(initialHeights1)
# initialHeightSD<-sd(initialHeights1)
# shapiro.test(initialHeights1)
# upperLimit<-oysterAvg+2*initialHeightSD
# lowerLimit<-oysterAvg-2*initialHeightSD
# initialHeights<-data.frame(initialHeights1)
# ggplot(initialHeights,aes(x=initialHeights1))+geom_histogram(binwidth = 5, fill="#69b3a2", color="#e9ecef")+theme_classic()+xlab("Shell height")+ylab("Frequency")
#
# FBout<-read.csv("FBout.csv")
#
# #Testing height for normality (all good)
# bag1height<- FBout[FBout$Bag == 1,"Height"]
# shapiro.test(bag1height)
# bag2height<- FBout[FBout$Bag == 2,"Height"]
# shapiro.test(bag2height)
# bag3height<- FBout[FBout$Bag == 3,"Height"]
# shapiro.test(bag3height)
# bag4height<- FBout[FBout$Bag == 4,"Height"]
# shapiro.test(bag4height)
#
# #Testing length for normality (all good)
# bag1length<- FBout[FBout$Bag == 1,"Length"]
# shapiro.test(bag1length)
# bag2length<- FBout[FBout$Bag == 2,"Length"]
# shapiro.test(bag2length)
# bag3length<- FBout[FBout$Bag == 3,"Length"]
# shapiro.test(bag3length)
# bag4length<- FBout[FBout$Bag == 4,"Length"]
# shapiro.test(bag4length)
#
# #Testing width for normality
# bag1width<- FBout[FBout$Bag == 1,"Width"]
# shapiro.test(bag1width) #Bag 1 good
# bag2width<- FBout[FBout$Bag == 2,"Width"]
# shapiro.test(bag2width) #Bag 2 not normal, p=0.0231
# bag3width<- FBout[FBout$Bag == 3,"Width"]
# shapiro.test(bag3width) #Bag 3 good
# bag4width<- FBout[FBout$Bag == 4,"Width"]
# shapiro.test(bag4width) #Bag 4 not normal, p=0.04589
#
# summary(FBout)
# NewBag<-as.character(FBout$Bag)
# FBout$Bag<-NewBag
# leveneTest(Height~Bag, data=FBout)
# HeightResults<-aov(Height~Bag, data=FBout)
# shapiro.test(HeightResults$residuals)
# summary(HeightResults)
#
# leveneTest(Length~Bag, data=FBout)
# LengthResults<-aov(Length~Bag, data=FBout)
# shapiro.test(LengthResults$residuals)
# summary(LengthResults)
#
# FBout$log.Width<-log(FBout$Width)
#
# bag1logwidth<- FBout[FBout$Bag == "1","log.Width"]
# shapiro.test(bag1logwidth)
# bag2logwidth<- FBout[FBout$Bag == "2","log.Width"]
# shapiro.test(bag2logwidth)
# bag3logwidth<- FBout[FBout$Bag == "3","log.Width"]
# shapiro.test(bag3logwidth)
# bag4logwidth<- FBout[FBout$Bag == "4","log.Width"]
# shapiro.test(bag4logwidth)
#
# kruskal.test(Width~Bag, data=FBout)
#
# WidthResults<-aov(Width~Bag, data=FBout)
# summary(WidthResults)
#
# ggplot(data = FBout, aes(x = Bag, y = Height))+geom_boxplot()+theme_classic()+xlab("Bag")+ylab("Height")+theme(text = element_text(size=12))
# ggplot(data = FBout, aes(x = Bag, y = Length))+geom_boxplot()+theme_classic()+xlab("Bag")+ylab("Length")+theme(text = element_text(size=12))
SamplingOne<-read.csv("6_14_22.csv")
SamplingNew<-SamplingOne[c(1:320,353:608),]
ggplot(data = SamplingNew, aes(x = Gear, y = Cup.ratio, fill=Location))+geom_boxplot()+scale_y_continuous(limits=c(0,0.5))
ggplot(data = SamplingNew, aes(x = Gear, y = Shell.shape, fill=Location))+geom_boxplot()+scale_y_continuous(limits=c(0,8))
library(Hmisc)
library(plotrix)
library(plyr)
turbidity<-read.csv("turbidity.csv")
turbidity$Date<-as.factor(turbidity$Date)
summarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE,
conf.interval=.95, .drop=TRUE) {
library(plyr)
# New version of length which can handle NA's: if na.rm==T, don't count them
length2 <- function (x, na.rm=FALSE) {
if (na.rm) sum(!is.na(x))
else length(x)
}
# This does the summary. For each group's data frame, return a vector with
# N, mean, and sd
datac <- ddply(data, groupvars, .drop=.drop,
.fun = function(xx, col) {
c(N = length2(xx[[col]], na.rm=na.rm),
mean = mean (xx[[col]], na.rm=na.rm),
sd = sd (xx[[col]], na.rm=na.rm)
)
},
measurevar
)
# Rename the "mean" column
datac <- rename(datac, c("mean" = measurevar))
datac$se <- datac$sd / sqrt(datac$N) # Calculate standard error of the mean
# Confidence interval multiplier for standard error
# Calculate t-statistic for confidence interval:
# e.g., if conf.interval is .95, use .975 (above/below), and use df=N-1
ciMult <- qt(conf.interval/2 + .5, datac$N-1)
datac$ci <- datac$se * ciMult
return(datac)
}
sumTurbidity<-summarySE(turbidity, measurevar="Turbidity", groupvars=c("Date", "Location"))
ggplot(sumTurbidity, aes(x=Date, y=Turbidity, group=Location,color=Location)) +
geom_errorbar(aes(ymin=Turbidity-se, ymax=Turbidity+se), width=.1) +
geom_line() +
geom_point()
#ANOVA storage
model.tables(cupRatioANOVA, type="means", se = TRUE)
#log transform
SamplingNew$log.cupRatio<-log(SamplingNew$Cup.ratio)
log.cupRatioANOVA <- aov(log.cupRatio ~ Gear * Location, data = SamplingNew)
summary(log.cupRatioANOVA)
leveneTest(log.cupRatio ~ Gear * Location, data = SamplingNew)
plot(log.cupRatioANOVA,1)
plot(log.cupRatioANOVA,2)
shapiro.test(log.cupRatioANOVA$residuals)