rBatt / trawl

Analysis of scientific trawl surveys of bottom-dwelling marine organisms
1 stars 0 forks source link

Function for n-strata vs. tolerance graph #8

Closed rBatt closed 9 years ago

rBatt commented 9 years ago

Create a function that does the equivalent of this:


nstrata <- c()
nstrata.orig <- c()
for(i in 0:(nyears-1)){
    nstrata[i+1] <- goa[,sum(colSums(table(year, strat2)>0)>=(nyears-i))]
    nstrata.orig[i+1] <- goa[,sum(colSums(table(year, stratum)>0)>=(nyears-i))]
}
dev.new(width=4)
par(mfrow=c(2,1), mar=c(2.5,2,1.5,0.2), cex=1, ps=10, mgp=c(1.25, 0.15, 0), tcl=-0.25)
plot(0:(nyears-1), nstrata, type="o", xlab="threshold # years missing", ylab="# strata below threshold missingness", main="# strata vs. tolerance of missingness")
lines(0:(nyears-1), nstrata.orig, type="o", col="red")
legend("topleft", legend=c("original strata definition", "1 degree grid definition"), lty=1, pch=21, col=c("red","black"))
image(x=goa[,sort(unique(year))], y=goa[,1:length(unique(strat2))], z=goa[,table(year, strat2)>0], xlab="year", ylab="1 degree stratum ID", main="stratum presence vs. time; red is absent")
rBatt commented 9 years ago

resolved d91331f42f7439674f97296a021e16796148dbcb