ok, the title is a bit bloated
but a very short code:
download.file("http://ices.dk/datacentre/StdGraphDB/FishStockDB.mdb",
"FishStockDB.mdb")
require(Hmisc) # need also mdbtools, in Fedora do >yum install mdbtools
FSDB <- mdb.get("FishStockDB.mdb")
require(plyr)
dat <- ddply(FSDB$Yieldrecruit[,c("FishStock","Age","Mat","F")],
c("FishStock"),transform,sel=F/max(F))
require(reshape2)
dat <- melt(dat[,c("FishStock","Age","Mat","sel")],id.vars=c("FishStock","Age"))
dat$variable <- ifelse(dat$variable %in% "Mat","Maturity","Selection")
require(ggplot2)
ggplot(dat,aes(Age,value,colour=variable)) +
geom_line() +
facet_wrap(~ FishStock) +
xlim(0,10)
ggsave("ICESmaturity.png")
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