># # Adapted from https://plot.ly/r/choropleth-maps/
># library(plotly)
>
># # light grey boundaries
># l <- list(color = toRGB("grey"), width = 0.5)
>
># # specify map projection/options
># g <- list(
>#   showframe = FALSE,
>#   showcoastlines = FALSE,
>#   projection = list(type = 'Mercator')
># )
>
># gdpGroups = rank(gdp.xlsx$Questions$`GDP $US`)
># reversegdpGroups = length(gdpGroups) + 1 - gdpGroups
># df = data.frame(gdp = `GDP in Billions`, COUNTRY = gdp.xlsx$Variables$Country, CODE = UN)
># p <- plot_geo(df) %>%
>#   add_trace(
>#     z = ~reversegdpGroups,
>#     text = ~COUNTRY, locations = ~CODE, marker = list(line = l)
>#   ) %>%
>#   colorbar(title = 'GDP Rank') %>%
>#   layout(
>#     #title = '2014 Global GDP<br>Source:<a href="https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html">CIA World Factbook</a>',
>#     geo = g
>#   )
># p.3 <- config(p, displayModeBar = FALSE)
># p.3
># Adapted from https://plot.ly/r/choropleth-maps/
>library(plotly)
Loading required package: ggplot2
Attaching package: 'plotly'

The following object is masked from 'package:ggplot2':

    last_plot

The following object is masked from 'package:stats':

    filter

The following object is masked from 'package:graphics':

    layout

>plot_geo(data.frame(GDP =  length(gdp) + 1 - rank(gdp.xlsx$Questions$`GDP $US`),
                    COUNTRY = gdp.xlsx$Variables$Country, CODE = UN)) %>%
    add_trace(z = ~GDP, color = ~GDP, text = ~COUNTRY, locations = ~CODE, 
      marker = list(line = list(color = toRGB("grey"), width = 0.5))) %>%# light grey boundaries
    colorbar(title = 'GDP Rank') %>%
    layout(geo = list(showframe = FALSE, showcoastlines = FALSE, projection = list(type = 'Mercator'))) %>%
    config(displayModeBar = FALSE)
Total time:0.45s
Time on R server:0.35s
Time evaluating code:0.19s
Bytes sent:12,036
Bytes received:15,839