Observations

library(knitr)
opts_knit$set(root.dir="../../..") # file paths are relative to the root of the project directory
library(tradeflows)
library(dplyr)
library(reshape2)
library(ggplot2)
library(xtable)
# # load raw data and rename it for direct evaluation of this template in RSTUDIO
# load("data/sawnwoodexample.rda") # if the format has change,
# rawdata <- sawnwood
# productcode_in_report = 4407
completeness <- rawdata %>% 
    select(reporter, classification, year, quantity, weight, tradevalue) %>%
    melt(id=c("reporter", "classification", "year"))  %>%
    mutate(value = !is.na(value)) %>%
    unique %>%
    group_by(reporter)

Product definitions

Product r productcode_in_report has the following definitions:

productname <- rawdata %>% 
    filter(productcode == productcode_in_report) %>%
    select(classification, product) %>%
    unique

for(code in productname$classification){
    cat("\n\n__",code,":__ ", sep="")
    cat(productname$product[productname$classification == code])
}

Summary

Number of reporting country by year and by classification type

kable

Completeness by country and by classification type

# Add product code and country name to the plot
for (r in unique(completeness$reporter)){
    cat("\n\n###", r, "\n")
    p <- ggplot(data=filter(completeness, reporter == r), 
                aes(x=year, y=variable, 
                    xend=year+1, yend=variable, 
                    color=value, linetype=value)) +
        geom_segment(size=3) + 
        facet_grid(classification~.) +
        ggtitle(paste("Data completeness of", productcode_in_report,
                      "in", r))
    plot(p)
    }


EuropeanForestInstitute/tradeflows documentation built on Oct. 7, 2019, 10:57 a.m.