# Prep data
myColors <- c("darkgreen", "darkred", "darkgoldenrod2")
myAreas <- c("World",
unique(agData_FAO_Region_Table$Region),
unique(agData_FAO_Region_Table$SubRegion),
unique(agData_FAO_Country_Table$Country))
xx <- d1 %>%
mutate(Value = ifelse(Measurement %in% c("Area Harvested", "Production"),
Value / 1000000, Value / 1000),
Unit = plyr::mapvalues(Unit, c("hectares", "tonnes", "kg/ha"),
c("Million Hectares", "Million Tonnes", "Tonnes/ Hectare")))
myAreas <- myAreas[myAreas %in% xx$Area]
# Plot
pdf("figures_lentil_fao.pdf", width = 12, height = 4)
for(i in myAreas) {
print(ggplot(xx %>% filter(Area == i)) +
geom_line(aes(x = Year, y = Value, color = Measurement),
size = 1.5, alpha = 0.7) +
facet_wrap(. ~ Measurement + Unit, ncol = 3, scales = "free_y") +
theme_agData(legend.position = "none",
axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_color_manual(values = myColors) +
scale_x_continuous(breaks = seq(1960, 2020, by = 5) ) +
labs(title = i, y = NULL, x = NULL, caption = myCaption) )
}
dev.off()