Created
December 5, 2013 17:46
-
-
Save karthik/7809986 to your computer and use it in GitHub Desktop.
eml_example.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rfisheries) | |
library(plyr) | |
library(reshape2) | |
species <- species_codes(progress = "text") | |
who <- c("TUX", "COD", "VET", "NPA") | |
by_species <- lapply(who, function(x) landings(species = x)) | |
names(by_species) <- who | |
dat <- melt(by_species, id = c("catch", "year")) | |
names(dat) <- c("catch", "year", "a3_code") | |
ggplot(dat, aes(year, catch)) + geom_line() + facet_wrap(~a3_code, scales = "free_y") | |
library(data.table) | |
species <- data.table(species) | |
setkey(species, "a3_code") | |
code_names <- species[who, scientific_name] | |
codes <- code_names$scientific_name | |
names(codes) <- code_names$a3_code | |
codes | |
meta <- list(catch = list("catch", "Global Landings of fish", "tonnes"), year = list("year", | |
"the year for which data was reported", "YYYY"), a3_code = list("a3_code", | |
"3 digit country code", codes)) | |
require(reml) | |
description <- "Landings data for several species by year, from the OpenFisheries database" | |
eml_write(dat = dat, meta, title = "Landings Data", description = description, | |
creator = "Karthik Ram <karthik@ropensci.org>", file = "landings.xml") | |
eml_publish("landings.xml", description = description, categories = "Ecology", | |
tags = "fisheries", destination = "figshare", visibility = "public") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment