-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPop_Biol_data_Milestone_5.R
175 lines (143 loc) · 5.28 KB
/
Pop_Biol_data_Milestone_5.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#clear environment
rm(list=ls(all=TRUE))
library(lattice)
library(latticeExtra)
library(grid)
library(gridBase)
library(plyr)
library(dplyr)
library(ggplot2)
library(scales)
library(extrafont)
library(extrafontdb)
library(scales)
library(reshape2)
setwd('F:/FRDC 7. Abalone recruitment/Data')
JUV<-read.csv('Juvenile_data_19_08_2016.csv', header = T )
# #replace NA with 0
# JUV[is.na(JUV)] <- 0
# summary(JUV)
JUV<-JUV[1:6]
#remove NA's
JUV<-JUV[complete.cases(JUV[,5]),]
summary(JUV)
JUV$String<-as.factor(JUV$String)
JUV$Plate<-as.factor(JUV$Plate)
# SORTING OUT THE DATES SO THEY ARE IN USEFUL FORMAT
#JUV$Date<-as.Date(JUV$Date, origin, format="%d/%m/%y")
JUV$newDate<-strptime(as.character(JUV$Date), "%d/%m/%Y")
JUV$newDate<-format(JUV$newDate, "%d/%b/%Y")
JUV$newDate<-as.Date(JUV$newDate, format="%d/%b/%Y")
# Betsey<-droplevels(subset(JUV, Location== "BI" & String== "2"))
# Betsey10<-droplevels(subset(Betsey, Plate >=5))
# Betsey10<-droplevels(subset(Betsey10, Plate <=7))
# #remove NAs
# Betsey10[complete.cases(Betsey10[,5]),]
ggplot(JUV, aes(x=Ab_SL, color=Location))+
geom_histogram(stat = "bin", colour="grey", binwidth = 5)+
scale_x_continuous(limits=c(0, 150))+
xlab("Shell Length (mm)") + ylab("Frequency") +
theme_bw()
ggplot(JUV, aes(x=Ab_SL)) +
ylab("Frequency") +
xlab("Shell Length (mm)")+
geom_histogram(alpha = 0.2, binwidth = 5)+
#ggtitle(paste(dum$SubBlockNo, FishYear))+
#labs(title= Yeardum$SubBlockNo, size=10)+
#geom_histogram(binwidth=50)+
theme_bw()+
facet_grid(. ~ Location)
#Ab_count <- ddply(JUV, "Date", summarise, Ab_ct = length(Ab_SL))
#rearregage DF giving number of juveniles by location, date and String.
Pick<-aggregate(x = JUV, by = list(JUV$Location, JUV$newDate, JUV$String), FUN = "length")
Pick<-Pick[1:4]
names(Pick)[names(Pick)=="Group.2"] <- "Date"
names(Pick)[names(Pick)=="Group.1"] <- "Site"
names(Pick)[names(Pick)=="Group.3"] <- "String"
names(Pick)[names(Pick)=="Location"] <- "Ab_Sum"
ggplot(Pick, aes(y=Ab_Sum, x=Date)) +
geom_bar(stat="identity")+
theme_bw()+
theme(axis.text.x = element_text(angle = 90, hjust = 1))+
facet_grid(. ~ Site)
#ggplot(Pick, aes(Ab_Sum, fill=Date)) + geom_bar(position="dodge")
#~~~~~~~~~~~~~~~~~~~~~~~~~BY SITE ~~~~~~~~~~~~~~~~~~~~~~~~~~~
#rearregage DF giving number of juveniles by location and date.
BI<-droplevels(subset(Pick, Pick$Site=="BI"))
BI$Date<-as.factor(BI$Date)
ggplot(BI, aes(y=Ab_Sum, x=Date, fill=String)) +
ggtitle("Betsey Island")+
xlab("Sample Date") +
ylab("Blacklip Abalone Abundance") +
geom_bar(stat="identity")+
scale_fill_grey(start = 0.3, end = 0.7)+
theme_bw()+
theme(axis.text.x = element_text(angle = 90, hjust = 0.5, vjust=0.2),
text = element_text(size=16),
legend.position=c(.95,.88))+
# scale_x_discrete(limits=c("27 Jun", "28 Jul", "18 Aug", "25 Sep", "08 Oct", "09 Oct"))
GIII<-droplevels(subset(Pick, Pick$Site=="GIII"))
ggplot(GIII, aes(y=Ab_Sum, x=Date, fill=String)) +
ggtitle("George 3rd Rock")+
xlab("Sample Date") +
ylab("Blacklip Abalone Abundance") +
geom_bar(stat="identity")+
ylim(0,50)+
scale_fill_grey(start = 0.3, end = 0.7)+
theme_bw()+
theme(axis.text.x = element_text(angle = 90, hjust = 0.5, vjust=0.2),
text = element_text(size=16),
legend.position=c(.95,.88))+
scale_x_discrete(limits=c("11 Aug", "21 Sep", "13 Oct"))
BR_B<-droplevels(subset(Pick, Pick$Site=="BR_B"))
ggplot(BR_B, aes(y=Ab_Sum, x=Date, fill=String)) +
ggtitle("Black Reef Boulder")+
xlab("Sample Date") +
ylab("Blacklip Abalone Abundance") +
geom_bar(stat="identity")+
ylim(0,50)+
scale_fill_grey(start = 0.3, end = 0.7)+
theme_bw()+
theme(axis.text.x = element_text(angle = 90, hjust = 0.5, vjust=0.2),
text = element_text(size=16),
legend.position=c(.95,.88))+
scale_x_discrete(limits=c("12 Aug", "30 Sep", "13 Oct"))
BR_S<-droplevels(subset(Pick, Pick$Site=="BR_S"))
ggplot(BR_S, aes(y=Ab_Sum, x=Date, fill=String)) +
ggtitle("Black Reef Slab")+
xlab("Sample Date") +
ylab("Blacklip Abalone Abundance") +
geom_bar(stat="identity")+
ylim(0,50)+
scale_fill_grey(start = 0.3, end = 0.7)+
theme_bw()+
theme(axis.text.x = element_text(angle = 90, hjust = 0.5, vjust=0.2),
text = element_text(size=16),
legend.position=c(.1,.87))+
scale_x_discrete(limits=c("24 Jul", "11 Aug", "30 Sep", "13 Oct"))
SP<-droplevels(subset(Pick, Pick$Site=="SP"))
ggplot(SP, aes(y=Ab_Sum, x=Date, fill=String)) +
ggtitle("Seymour Point")+
xlab("Sample Date") +
ylab("Blacklip Abalone Abundance") +
geom_bar(stat="identity")+
ylim(0,50)+
scale_fill_grey(start = 0.3, end = 0.7)+
theme_bw()+
theme(axis.text.x = element_text(angle = 90, hjust = 0.5, vjust=0.2),
text = element_text(size=16),
legend.position=c(.1,.87))+
scale_x_discrete(limits=c("29 Jul", "20 Aug", "09 Sep"))
TG<-droplevels(subset(Pick, Pick$Site=="TG"))
ggplot(TG, aes(y=Ab_Sum, x=Date, fill=String)) +
ggtitle("The Gardens")+
xlab("Sample Date") +
ylab("Blacklip Abalone Abundance") +
geom_bar(stat="identity")+
ylim(0,50)+
scale_fill_grey(start = 0.3, end = 0.7)+
theme_bw()+
theme(axis.text.x = element_text(angle = 90, hjust = 0.5, vjust=0.2),
text = element_text(size=16),
legend.position=c(.1,.87))+
scale_x_discrete(limits=c("29 Jul", "20 Aug", "09 Sep"))