library(WDI)
library(dplyr)
library(plotly)
library(ggplot2)
library(magrittr)

countries <- c("ZA", "BW", "ZW")


men <- WDI(country = countries, indicator = "SP.DYN.LE00.MA.IN", start = 1990, end = 2012)

women <- WDI(country = countries, indicator = "SP.DYN.LE00.FE.IN", start = 1990, end = 2012)

men$country <- paste0(men$country, " (men)")

women$country <- paste0(women$country, " (women)")

men %<>% rename(lex = SP.DYN.LE00.MA.IN)

women %<>% rename(lex = SP.DYN.LE00.FE.IN)

full <- rbind(men, women) %>%
  arrange(iso2c, country)


g <- ggplot(full, aes(x = year, y = lex, color = country)) + 
  geom_line() + 
  theme_bw() + 
  scale_color_manual(values = c("#393b79", "#9c9ede", "#843c39", "#e7969c", "#637939", "#cedb9c"))


py <- plotly(username = "walkerke", key = "my_api_key")


py$ggplotly(g)