observer.compute.fisheries.exploitation = function(a) {
## USED ??
a$dummy= 1
a$hardness = ifelse(a$durometre>=68, 1, 0)
# calculate counts of hard and total crab for each trip set
b = xtabs( as.integer(a$hardness) ~ as.factor(a$tripset) )
b = as.data.frame(b)
names(b) = c("tripset", "no.hard")
c = xtabs( as.integer(a$dummy) ~ as.factor(a$tripset))
c = as.data.frame(c)
names(c)= c("tripset", "total")
# merge two new data frames
d = merge( x=b, y=c, by="tripset", all.x=F, all.y=T, sort=F )
d$percenthard = (d$no.hard/d$total)*100
d$percentsoft = 100 - d$percenthard
# import catch rate from a
e = tapply( X=a$kgpertrap, INDEX=a$tripset, FUN=function(q){unique(q)[1]})
e = as.data.frame(e)
f = data.frame(kgpertrap=as.vector(e$e), tripset=dimnames(e)[[1]] )
f$tripset = as.character( f$tripset )
g=merge(x=d, y=f, by="tripset", all.x=F, all.y=T, sort=F)
# import latitude from a
h = tapply(X=a$lat, INDEX= a$tripset, FUN= function(q){unique(q)[1]})
h = as.data.frame(h)
i = data.frame(lat=as.vector(h$h), tripset=dimnames(h)[[1]] )
i$tripset = as.character(i$tripset)
j = merge(x=g, y=i, by="tripset", all.x=F, all.y=T, sort=F)
# import longitude from a
k = tapply(X=a$lon, INDEX= a$tripset, FUN= function(q){unique(q)[1]})
k = as.data.frame(k)
l = data.frame(lon=as.vector(k$k), tripset=dimnames(k)[[1]] )
l$tripset = as.character(l$tripset)
m = merge(x=j, y=l, by="tripset", all.x=F, all.y=T, sort=F)
# import estimated catch from a
n = tapply(X=a$EST_CATCH, INDEX= a$tripset, FUN= function(q){unique(q)[1]})
n = as.data.frame(n)
p = data.frame(EST_CATCH=as.vector(n$n), tripset=dimnames(n)[[1]] )
p$tripset = as.character(p$tripset)
q = merge(x=m, y=p, by="tripset", all.x=F, all.y=T, sort=F)
q$discardkg = (q$EST_CATCH*1000)*(q$percentsoft/100)
# divide into north, south, and 4X by positions
source("C:/Scripts/geo.filter.r")
northdata= q[polygon_inside(q,aegis.polygons::polygon_internal_code("cfanorth")),]
nens=northdata
southdata= q[polygon_inside(q,aegis.polygons::polygon_internal_code("cfasouth")),]
sens=southdata
cfa23data= q[polygon_inside(q,aegis.polygons::polygon_internal_code("cfa23")),]
cfa23=cfa23data
cfa24data= q[polygon_inside(q,aegis.polygons::polygon_internal_code("cfa24")),]
cfa24=cfa24data
cfa4xdata= q[polygon_inside(q,aegis.polygons::polygon_internal_code("cfa4x")),]
cfa4x=cfa4xdata
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.