Friday, April 13, 2012

ICES maturity: datamining, MS Access, R, plyr, reshape2 and ggplot2

ok, the title is a bit bloated

but a very short code:
require(Hmisc) # need also mdbtools, in Fedora do  >yum install mdbtools
FSDB <- mdb.get("FishStockDB.mdb")
dat <- ddply(FSDB$Yieldrecruit[,c("FishStock","Age","Mat","F")],
dat <- melt(dat[,c("FishStock","Age","Mat","sel")],id.vars=c("FishStock","Age"))
dat$variable <- ifelse(dat$variable %in% "Mat","Maturity","Selection")
ggplot(dat,aes(Age,value,colour=variable)) + 
  geom_line() + 
  facet_wrap(~ FishStock) +
is behind this picture.

and it demonstrates how to:
download data
access MS Access mdb files via R
use plyr
use reshape2
use ggplot2

the resulting graph poses on the other hand, myriads of fisheries related questions. be they biological and/or management. like the question if there is a pattern between the sync/out-of-sync in the fisheries selection pattern and the biological pattern (here maturity) and the state of the stock/fisheries? leave that  for somebody else to determine.

No comments:

Post a Comment