head(production)
# Analyze production measured in tonnes
prod <- production[production$measure == "Q_tlw" & production$value > 0,]
# Fast merge yearbook and inlandmarine columns
prod$yearbook <- species$yearbook[match(prod$species, species$species)]
prod$inlandmarine <- area$inlandmarine[match(prod$area, area$area)]
# Select SOFIA species, excluding mammals, reptiles, and plants
prod <- prod[grep("Fish, crustaceans and molluscs", prod$yearbook, fixed=TRUE),]
# Determine origin
prod$origin <- ifelse(prod$source == "CAPTURE", "Capture", "Aquaculture")
prod$w <- ifelse(prod$inlandmarine == "Marine areas", "marine", "inland")
prod$origin <- paste0(prod$origin, " (", prod$w, ")")
cbind(sort(unique(prod$origin)))
# World capture fisheries and aquaculture production
x <- xtabs(value~year+origin, aggregate(value~year+origin, prod, sum))
x <- x[,c(2,1,4,3)] / 1e6
library(areaplot)
areaplot(x, legend=TRUE, args.legend=list(x="topleft"), ylab="million tonnes")
Run the code above in your browser using DataLab