jules32/ohiprep — pull request #4 by bbest (2014-06-08 23:08:35+00:00)
Title: finished FAO-Commodities data files for NP (OHI-Science/ohicore#34)

Hi @jules32,

I carried forward the previous year's value if the one for the max(year) was NA by using [dplyr's window functions](http://cran.r-project.org/web/packages/dplyr/vignettes/window-functions.html) (specifically the `lag()` function). Check it at [data_prep.R#L107-L115](https://github.com/bbest/ohiprep/blob/c69adbd01cb8e02aea8d17b3982083e113e04289/Global/FAO-Commodities_v2011/data_prep.R#L107-L115).

I moved the lookup for going from FAO commodities to Natural Products categories to table Global/FAO-Commodities_v2011/commodities2categories.csv. Note that I've also added a README.Rmd which outputs that table into the README.md when knitted from RStudio. (Since the README.html is redundant with the README.md, I added README.html to Global/FAO-Commodities_v2011/.gitignore by right-clicking on the file listing in RStudio's Git pane.)

I created a new function `cbind_rgn()` to supersede `add_rgn_id()` (in src/R/ohi_clean_fxns.R), since I wanted a function to return the data.frame and not write to csv.

There are many updates to the Global/FAO-Commodities_v2011/data_prep.R. You'll pickup some cool tricks by comparing with the previous version (see History in Github).

It'd be great for you to consider:

- These commodities are present in the lookup and not found in the data. Are you OK with simply removing them from Global/FAO-Commodities_v2011/commodities2categories.csv?
+ fish_oil: 'Pilchard oil','Jack mackerel oil','Gadoid liver oils, nei','Anchoveta oil','Alaska pollack oil, nei'
- These commodiates are present in the data and not found in the lookup, by keywords. Should these be added?
+ 'shell': 'Powder and waste of shells'
+ 'oil': 'Aquatic animals oils and fats, nei, 'Oils and fats of aquatic animals, nei'

For the country to rgn_id lookup:
- renamed in the data_prep.R:
+ Sint-Eustasius to Sint Eustatius
+ Sint-Maarten to Sint Maarten
- and added to src/LookupTables/rgn_eez_v2013a_synonyms.csv:
+ 56,73,**Un. Sov. Soc. Rep.**,RU,RUS,ohi_region