{"size":{"Width":780,"Height":400},"appearance":{"background":null,"padding":14,"font":{"family":"Courier New","size":10.0,"bold":false,"italic":false,"underline":false,"strikeout":false,"color":"rgb(0,72,168)"},"border":{"on":true,"size":0.0,"style":"solid","color":"#666"},"text":{"wrap":false,"hAlign":"left","vAlign":"top"}},"outputType":"WIDGET","widgetState":null,"outputs":{"console":"<pre class='debug-source'>&gt;# # Adapted from https://plot.ly/r/choropleth-maps/\n</pre>\n<pre class='debug-source'>&gt;# library(plotly)\n</pre>\n<pre class='debug-source'>&gt;\n</pre>\n<pre class='debug-source'>&gt;# # light grey boundaries\n</pre>\n<pre class='debug-source'>&gt;# l &lt;- list(color = toRGB(&quot;grey&quot;), width = 0.5)\n</pre>\n<pre class='debug-source'>&gt;\n</pre>\n<pre class='debug-source'>&gt;# # specify map projection/options\n</pre>\n<pre class='debug-source'>&gt;# g &lt;- list(\n</pre>\n<pre class='debug-source'>&gt;# showframe = FALSE,\n</pre>\n<pre class='debug-source'>&gt;# showcoastlines = FALSE,\n</pre>\n<pre class='debug-source'>&gt;# projection = list(type = &#39;Mercator&#39;)\n</pre>\n<pre class='debug-source'>&gt;# )\n</pre>\n<pre class='debug-source'>&gt;\n</pre>\n<pre class='debug-source'>&gt;# gdpGroups = rank(gdp.xlsx$Questions$`GDP $US`)\n</pre>\n<pre class='debug-source'>&gt;# reversegdpGroups = length(gdpGroups) + 1 - gdpGroups\n</pre>\n<pre class='debug-source'>&gt;# df = data.frame(gdp = `GDP in Billions`, COUNTRY = gdp.xlsx$Variables$Country, CODE = UN)\n</pre>\n<pre class='debug-source'>&gt;# p &lt;- plot_geo(df) %&gt;%\n</pre>\n<pre class='debug-source'>&gt;# add_trace(\n</pre>\n<pre class='debug-source'>&gt;# z = ~reversegdpGroups,\n</pre>\n<pre class='debug-source'>&gt;# text = ~COUNTRY, locations = ~CODE, marker = list(line = l)\n</pre>\n<pre class='debug-source'>&gt;# ) %&gt;%\n</pre>\n<pre class='debug-source'>&gt;# colorbar(title = &#39;GDP Rank&#39;) %&gt;%\n</pre>\n<pre class='debug-source'>&gt;# layout(\n</pre>\n<pre class='debug-source'>&gt;# #title = &#39;2014 Global GDP&lt;br&gt;Source:&lt;a href=&quot;https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html&quot;&gt;CIA World Factbook&lt;/a&gt;&#39;,\n</pre>\n<pre class='debug-source'>&gt;# geo = g\n</pre>\n<pre class='debug-source'>&gt;# )\n</pre>\n<pre class='debug-source'>&gt;# p.3 &lt;- config(p, displayModeBar = FALSE)\n</pre>\n<pre class='debug-source'>&gt;# p.3\n</pre>\n<pre class='debug-source'>&gt;# Adapted from https://plot.ly/r/choropleth-maps/\n</pre>\n<pre class='debug-source'>&gt;library(plotly)\n</pre>\n<pre class='debug-message'>Loading required package: ggplot2\n</pre>\n<pre class='debug-message'>\nAttaching package: &#39;plotly&#39;\n\n</pre>\n<pre class='debug-message'>The following object is masked from &#39;package:ggplot2&#39;:\n\n last_plot\n\n</pre>\n<pre class='debug-message'>The following object is masked from &#39;package:stats&#39;:\n\n filter\n\n</pre>\n<pre class='debug-message'>The following object is masked from &#39;package:graphics&#39;:\n\n layout\n\n</pre>\n<pre class='debug-source'>&gt;plot_geo(data.frame(GDP = length(gdp) + 1 - rank(gdp.xlsx$Questions$`GDP $US`),\n COUNTRY = gdp.xlsx$Variables$Country, CODE = UN)) %&gt;%\n add_trace(z = ~GDP, color = ~GDP, text = ~COUNTRY, locations = ~CODE, \n marker = list(line = list(color = toRGB(&quot;grey&quot;), width = 0.5))) %&gt;%# light grey boundaries\n colorbar(title = &#39;GDP Rank&#39;) %&gt;%\n layout(geo = list(showframe = FALSE, showcoastlines = FALSE, projection = list(type = &#39;Mercator&#39;))) %&gt;%\n config(displayModeBar = FALSE)\n</pre>\r\n<div class=\"debug-summarystatistics\">\r\n<table>\r\n<tr><th>Total time:</th><td>0.45s</td></tr>\r\n<tr><th>Time on R server:</th><td title=\"rApacheServe 0.35s (pre 0.01s, post 0.00s) httpget_code() setup for eval 0.01s session$eval 0.32s (pre 0.00s, post 0.10s) unexplained 0.02s apparmor forking (pre 0.03s, post 0.00s)\">0.35s</td></tr>\r\n<tr><th>Time evaluating code:</th><td>0.19s</td></tr>\r\n<tr><th>Bytes sent:</th><td>12,036</td></tr>\r\n<tr><th>Bytes received:</th><td>15,839</td></tr>\r\n</table>\r\n</div>","message":"Loading required package: ggplot2\n\r\n\nAttaching package: 'plotly'\n\n\r\nThe following object is masked from 'package:ggplot2':\n\n last_plot\n\n\r\nThe following object is masked from 'package:stats':\n\n filter\n\n\r\nThe following object is masked from 'package:graphics':\n\n layout\n\n","htmlwidgets":"<div id=\"htmlwidget_container\">\n <div id=\"htmlwidget-213f3041af45\" style=\"width:100%;height:400px;\" class=\"plotly html-widget\"></div>\n</div>\n<script type=\"application/json\" data-for=\"htmlwidget-213f3041af45\">{\"x\":{\"visdat\":{\"213f5947d8af\":[\"function () \",\"plotlyVisDat\"]},\"cur_data\":\"213f5947d8af\",\"attrs\":{\"213f5947d8af\":{\"alpha\":1,\"sizes\":[10,100],\"z\":{},\"color\":{},\"text\":{},\"locations\":{},\"marker\":{\"line\":{\"color\":\"rgba(190,190,190,1)\",\"width\":0.5}}}},\"layout\":{\"margin\":{\"b\":40,\"l\":60,\"t\":25,\"r\":10},\"mapType\":\"geo\",\"scene\":{\"zaxis\":{\"title\":\"GDP\"}},\"geo\":{\"domain\":{\"x\":[0,1],\"y\":[0,1]},\"showframe\":false,\"showcoastlines\":false,\"projection\":{\"type\":\"Mercator\"}},\"hovermode\":\"closest\",\"showlegend\":false,\"legend\":{\"y\":0.5,\"yanchor\":\"top\"}},\"source\":\"A\",\"config\":{\"modeBarButtonsToAdd\":[{\"name\":\"Collaborate\",\"icon\":{\"width\":1000,\"ascent\":500,\"descent\":-50,\"path\":\"M487 375c7-10 9-23 5-36l-79-259c-3-12-11-23-22-31-11-8-22-12-35-12l-263 0c-15 0-29 5-43 15-13 10-23 23-28 37-5 13-5 25-1 37 0 0 0 3 1 7 1 5 1 8 1 11 0 2 0 4-1 6 0 3-1 5-1 6 1 2 2 4 3 6 1 2 2 4 4 6 2 3 4 5 5 7 5 7 9 16 13 26 4 10 7 19 9 26 0 2 0 5 0 9-1 4-1 6 0 8 0 2 2 5 4 8 3 3 5 5 5 7 4 6 8 15 12 26 4 11 7 19 7 26 1 1 0 4 0 9-1 4-1 7 0 8 1 2 3 5 6 8 4 4 6 6 6 7 4 5 8 13 13 24 4 11 7 20 7 28 1 1 0 4 0 7-1 3-1 6-1 7 0 2 1 4 3 6 1 1 3 4 5 6 2 3 3 5 5 6 1 2 3 5 4 9 2 3 3 7 5 10 1 3 2 6 4 10 2 4 4 7 6 9 2 3 4 5 7 7 3 2 7 3 11 3 3 0 8 0 13-1l0-1c7 2 12 2 14 2l218 0c14 0 25-5 32-16 8-10 10-23 6-37l-79-259c-7-22-13-37-20-43-7-7-19-10-37-10l-248 0c-5 0-9-2-11-5-2-3-2-7 0-12 4-13 18-20 41-20l264 0c5 0 10 2 16 5 5 3 8 6 10 11l85 282c2 5 2 10 2 17 7-3 13-7 17-13z m-304 0c-1-3-1-5 0-7 1-1 3-2 6-2l174 0c2 0 4 1 7 2 2 2 4 4 5 7l6 18c0 3 0 5-1 7-1 1-3 2-6 2l-173 0c-3 0-5-1-8-2-2-2-4-4-4-7z m-24-73c-1-3-1-5 0-7 2-2 3-2 6-2l174 0c2 0 5 0 7 2 3 2 4 4 5 7l6 18c1 2 0 5-1 6-1 2-3 3-5 3l-174 0c-3 0-5-1-7-3-3-1-4-4-5-6z\"},\"click\":\"function(gd) { \\n // is this being viewed in RStudio?\\n if (location.search == '?viewer_pane=1') {\\n alert('To learn about plotly for collaboration, visit:\\\\n https://cpsievert.github.io/plotly_book/plot-ly-for-collaboration.html');\\n } else {\\n window.open('https://cpsievert.github.io/plotly_book/plot-ly-for-collaboration.html', '_blank');\\n }\\n }\"}],\"cloud\":false,\"displayModeBar\":false},\"data\":[{\"colorbar\":{\"title\":\"GDP Rank\",\"ticklen\":2,\"len\":0.5,\"y\":1,\"lenmode\":\"fraction\",\"yanchor\":\"top\"},\"colorscale\":[[\"0\",\"rgba(68,1,84,1)\"],[\"0.0416666666666667\",\"rgba(70,19,97,1)\"],[\"0.0833333333333333\",\"rgba(72,32,111,1)\"],[\"0.125\",\"rgba(71,45,122,1)\"],[\"0.166666666666667\",\"rgba(68,58,128,1)\"],[\"0.208333333333333\",\"rgba(64,70,135,1)\"],[\"0.25\",\"rgba(60,82,138,1)\"],[\"0.291666666666667\",\"rgba(56,93,140,1)\"],[\"0.333333333333333\",\"rgba(49,104,142,1)\"],[\"0.375\",\"rgba(46,114,142,1)\"],[\"0.416666666666667\",\"rgba(42,123,142,1)\"],[\"0.458333333333333\",\"rgba(38,133,141,1)\"],[\"0.5\",\"rgba(37,144,140,1)\"],[\"0.541666666666667\",\"rgba(33,154,138,1)\"],[\"0.583333333333333\",\"rgba(39,164,133,1)\"],[\"0.625\",\"rgba(47,174,127,1)\"],[\"0.666666666666667\",\"rgba(53,183,121,1)\"],[\"0.708333333333333\",\"rgba(79,191,110,1)\"],[\"0.75\",\"rgba(98,199,98,1)\"],[\"0.791666666666667\",\"rgba(119,207,85,1)\"],[\"0.833333333333333\",\"rgba(147,214,70,1)\"],[\"0.875\",\"rgba(172,220,52,1)\"],[\"0.916666666666667\",\"rgba(199,225,42,1)\"],[\"0.958333333333333\",\"rgba(226,228,40,1)\"],[\"1\",\"rgba(253,231,37,1)\"]],\"showscale\":true,\"z\":[52,61,134,112,120,156,98,163,161,131,176,137,90,162,31,129,65,115,171,83,143,169,89,67,158,159,130,145,116,146,119,57,124,128,138,26,135,179,113,166,152,144,37,133,59,151,80,149,84,97,106,110,107,92,43,157,122,69,104,2,165,7,16,27,51,32,3,85,54,11,56,142,111,78,36,154,123,101,71,39,34,53,12,20,35,64,139,25,17,88,30,70,45,95,121,127,28,86,79,24,109,76,77,105,47,33,99,42,6,114,4,46,55,103,38,8,93,141,82,72,126,125,140,150,18,29,23,44,49,87,62,81,13,22,19,60,5,164,132,148,160,10,73,63,177,66,96,170,68,136,100,117,15,118,74,172,167,175,102,1,14,147,183,182,180,184,50,181,108,173,168,178,185,174,21,91,9,41,40,58,155,94,48,153,75],\"text\":[\"Algeria\",\"Angola\",\"Benin\",\"Botswana\",\"Burkina Faso\",\"Burundi\",\"Cameroon\",\"Cape Verde\",\"Central African Republic\",\"Chad\",\"Comoros\",\"Congo\",\"Democratic Republic of the Congo\",\"Djibouti\",\"Egypt\",\"Equatorial Guinea\",\"Ethiopia\",\"Gabon\",\"Gambia\",\"Ghana\",\"Guinea\",\"Guinea-Bissau\",\"Cote d'Ivoire\",\"Kenya\",\"Lesotho\",\"Liberia\",\"Madagascar\",\"Malawi\",\"Mali\",\"Mauritania\",\"Mauritius\",\"Morocco\",\"Mozambique\",\"Namibia\",\"Niger\",\"Nigeria\",\"Rwanda\",\"Sao Tome and Principe\",\"Senegal\",\"Seychelles\",\"Sierra Leone\",\"Somalia\",\"South Africa\",\"South Sudan\",\"Sudan\",\"Swaziland\",\"Tanzania\",\"Togo\",\"Tunisia\",\"Uganda\",\"Zambia\",\"Zimbabwe\",\"Afghanistan\",\"Bahrain\",\"Bangladesh\",\"Bhutan\",\"Brunei Darussalam\",\"Myanmar\",\"Cambodia\",\"China\",\"Timor-Leste\",\"India\",\"Indonesia\",\"Iran\",\"Iraq\",\"Israel\",\"Japan\",\"Jordan\",\"Kazakhstan\",\"South Korea\",\"Kuwait\",\"Kyrgyzstan\",\"Lao\",\"Lebanon\",\"Malaysia\",\"Maldives\",\"Mongolia\",\"Nepal\",\"Oman\",\"Pakistan\",\"Philippines\",\"Qatar\",\"Russian Federation\",\"Saudi Arabia\",\"Singapore\",\"Sri Lanka\",\"Tajikistan\",\"Thailand\",\"Turkey\",\"Turkmenistan\",\"United Arab Emirates\",\"Uzbekistan\",\"Vietnam\",\"Yemen\",\"Albania\",\"Armenia\",\"Austria\",\"Azerbaijan\",\"Belarus\",\"Belgium\",\"Bosnia and Herzegovina\",\"Bulgaria\",\"Croatia\",\"Cyprus\",\"Czech Republic\",\"Denmark\",\"Estonia\",\"Finland\",\"France\",\"Georgia\",\"Germany\",\"Greece\",\"Hungary\",\"Iceland\",\"Ireland\",\"Italy\",\"Latvia\",\"Liechtenstein\",\"Lithuania\",\"Luxembourg\",\"Macedonia\",\"Malta\",\"Moldova\",\"Montenegro\",\"Netherlands\",\"Norway\",\"Poland\",\"Portugal\",\"Romania\",\"Serbia\",\"Slovakia\",\"Slovenia\",\"Spain\",\"Sweden\",\"Switzerland\",\"Ukraine\",\"United Kingdom\",\"Antigua and Barbuda\",\"Bahamas\",\"Barbados\",\"Belize\",\"Canada\",\"Costa Rica\",\"Cuba\",\"Dominica\",\"Dominican Republic\",\"El Salvador\",\"Grenada\",\"Guatemala\",\"Haiti\",\"Honduras\",\"Jamaica\",\"Mexico\",\"Nicaragua\",\"Panama\",\"St. Kitts and Nevis\",\"St. Lucia\",\"St. Vincent and the Grenadines\",\"Trinidad and Tobago\",\"United States\",\"Australia\",\"Fiji\",\"Kiribati\",\"Marshall Islands\",\"Micronesia\",\"Nauru\",\"New Zealand\",\"Palau\",\"Papua New Guinea\",\"Samoa\",\"Solomon Islands\",\"Tonga\",\"Tuvalu\",\"Vanuatu\",\"Argentina\",\"Bolivia\",\"Brazil\",\"Chile\",\"Colombia\",\"Ecuador\",\"Guyana\",\"Paraguay\",\"Peru\",\"Suriname\",\"Uruguay\"],\"locations\":[\"DZA\",\"AGO\",\"BEN\",\"BWA\",\"BFA\",\"BDI\",\"CMR\",\"CPV\",\"CAF\",\"TCD\",\"COM\",\"COG\",\"COD\",\"DJI\",\"EGY\",\"GNQ\",\"ETH\",\"GAB\",\"GMB\",\"GHA\",\"GIN\",\"GNB\",\"CIV\",\"KEN\",\"LSO\",\"LBR\",\"MDG\",\"MWI\",\"MLI\",\"MRT\",\"MUS\",\"MAR\",\"MOZ\",\"NAM\",\"NER\",\"NGA\",\"RWA\",\"STP\",\"SEN\",\"SYC\",\"SLE\",\"SOM\",\"ZAF\",\"SSD\",\"SDN\",\"SWZ\",\"TZA\",\"TGO\",\"TUN\",\"UGA\",\"ZMB\",\"ZWE\",\"AFG\",\"BHR\",\"BGD\",\"BTN\",\"BRN\",\"MMR\",\"KHM\",\"CHN\",\"TLS\",\"IND\",\"IDN\",\"IRN\",\"IRQ\",\"ISR\",\"JPN\",\"JOR\",\"KAZ\",\"PRK\",\"KWT\",\"KGZ\",\"LAO\",\"LBN\",\"MYS\",\"MDV\",\"MNG\",\"NPL\",\"OMN\",\"PAK\",\"PHL\",\"QAT\",\"RUS\",\"SAU\",\"SGP\",\"LKA\",\"TJK\",\"THA\",\"TUR\",\"TKM\",\"ARE\",\"UZB\",\"VNM\",\"YEM\",\"ALB\",\"ARM\",\"AUT\",\"AZE\",\"BLR\",\"BEL\",\"BIH\",\"BGR\",\"HRV\",\"CYP\",\"CZE\",\"DNK\",\"EST\",\"FIN\",\"FRA\",\"GEO\",\"DEU\",\"GRC\",\"HUN\",\"ISL\",\"IRL\",\"ITA\",\"LVA\",\"LIE\",\"LTU\",\"LUX\",\"MKD\",\"MLT\",\"MDA\",\"MNE\",\"NLD\",\"NOR\",\"POL\",\"PRT\",\"ROU\",\"SRB\",\"SVK\",\"SVN\",\"ESP\",\"SWE\",\"CHE\",\"UKR\",\"GBR\",\"ATG\",\"BHS\",\"BRB\",\"BLZ\",\"CAN\",\"CRI\",\"CUB\",\"DMA\",\"DOM\",\"SLV\",\"GRD\",\"GTM\",\"HTI\",\"HND\",\"JAM\",\"MEX\",\"NIC\",\"PAN\",\"KNA\",\"LCA\",\"VCT\",\"TTO\",\"USA\",\"AUS\",\"FJI\",\"KIR\",\"MHL\",\"FSM\",\"NRU\",\"NZL\",\"PLW\",\"PNG\",\"WSM\",\"SLB\",\"TON\",\"TUV\",\"VUT\",\"ARG\",\"BOL\",\"BRA\",\"CHL\",\"COL\",\"ECU\",\"GUY\",\"PRY\",\"PER\",\"SUR\",\"URY\"],\"marker\":{\"line\":{\"color\":\"rgba(190,190,190,1)\",\"width\":0.5}},\"type\":\"choropleth\",\"geo\":\"geo\",\"frame\":null}],\"highlight\":{\"on\":\"plotly_click\",\"persistent\":false,\"dynamic\":false,\"selectize\":false,\"opacityDim\":0.2,\"selected\":{\"opacity\":1}},\"base_url\":\"https://plot.ly\"},\"evals\":[\"config.modeBarButtonsToAdd.0.click\"],\"jsHooks\":{\"render\":[{\"code\":\"function(el, x) { var ctConfig = crosstalk.var('plotlyCrosstalkOpts').set({\\\"on\\\":\\\"plotly_click\\\",\\\"persistent\\\":false,\\\"dynamic\\\":false,\\\"selectize\\\":false,\\\"opacityDim\\\":0.2,\\\"selected\\\":{\\\"opacity\\\":1}}); }\",\"data\":null},{\"code\":\"function(el, x) { var ctConfig = crosstalk.var('plotlyCrosstalkOpts').set({\\\"on\\\":\\\"plotly_click\\\",\\\"persistent\\\":false,\\\"dynamic\\\":false,\\\"selectize\\\":false,\\\"opacityDim\\\":0.2,\\\"selected\\\":{\\\"opacity\\\":1}}); }\",\"data\":null}]}}</script>\n<script type=\"application/htmlwidget-sizing\" data-for=\"htmlwidget-213f3041af45\">{\"viewer\":{\"width\":\"100%\",\"height\":400,\"padding\":15,\"fill\":true},\"browser\":{\"width\":\"100%\",\"height\":400,\"padding\":40,\"fill\":true}}</script>","htmlwidget-head":"{\"stylesheets\":[\"https://rserverhtmlwidgetasset.azureedge.net/crosstalk-b25ccf47e9892cf2654d5ded8a45d9b7.css\",\"https://rserverhtmlwidgetasset.azureedge.net/plotly-htmlwidgets-ef6d87e1454c6f9f50a1a5a3e8b42646.css\"],\"javascript\":[\"https://rserverhtmlwidgetasset.azureedge.net/htmlwidgets-cd5c5716917807e1b69e2493221698b2.js\",\"https://rserverhtmlwidgetasset.azureedge.net/plotly-4ab51328a91fb22cf606710cfee204c9.js\",\"https://rserverhtmlwidgetasset.azureedge.net/typedarray.min-830ee97537deb99885d830da3312e14d.js\",\"https://rserverhtmlwidgetasset.azureedge.net/jquery.min-91a24ea414e8c447d647cecab86866c2.js\",\"https://rserverhtmlwidgetasset.azureedge.net/crosstalk.min-b1936a0f8f135773de79f3a54af76d20.js\",\"https://rserverhtmlwidgetasset.azureedge.net/plotly-latest.min-325c88418cec885e677571e996ab3377.js\"],\"attachments\":[]}","warning":"","visible":"yes"},"secondsTaken":0.45466330000000005,"updated":"2017-09-08T01:49:48.4010467Z","lastUpdatedMessage":null,"executedCode":"# # Adapted from https://plot.ly/r/choropleth-maps/\n# library(plotly)\n\n# # light grey boundaries\n# l <- list(color = toRGB(\"grey\"), width = 0.5)\n\n# # specify map projection/options\n# g <- list(\n# showframe = FALSE,\n# showcoastlines = FALSE,\n# projection = list(type = 'Mercator')\n# )\n\n# gdpGroups = rank(gdp.xlsx$Questions$`GDP $US`)\n# reversegdpGroups = length(gdpGroups) + 1 - gdpGroups\n# df = data.frame(gdp = `GDP in Billions`, COUNTRY = gdp.xlsx$Variables$Country, CODE = UN)\n# p <- plot_geo(df) %>%\n# add_trace(\n# z = ~reversegdpGroups,\n# text = ~COUNTRY, locations = ~CODE, marker = list(line = l)\n# ) %>%\n# colorbar(title = 'GDP Rank') %>%\n# layout(\n# #title = '2014 Global GDP<br>Source:<a href=\"https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html\">CIA World Factbook</a>',\n# geo = g\n# )\n# p.3 <- config(p, displayModeBar = FALSE)\n# p.3\n# Adapted from https://plot.ly/r/choropleth-maps/\nlibrary(plotly)\nplot_geo(data.frame(GDP = length(gdp) + 1 - rank(gdp.xlsx$Questions$`GDP $US`),\n COUNTRY = gdp.xlsx$Variables$Country, CODE = UN)) %>%\n add_trace(z = ~GDP, color = ~GDP, text = ~COUNTRY, locations = ~CODE, \n marker = list(line = list(color = toRGB(\"grey\"), width = 0.5))) %>%# light grey boundaries\n colorbar(title = 'GDP Rank') %>%\n layout(geo = list(showframe = FALSE, showcoastlines = FALSE, projection = list(type = 'Mercator'))) %>%\n config(displayModeBar = FALSE)","lastSavedCode":"# # Adapted from https://plot.ly/r/choropleth-maps/\n# library(plotly)\n\n# # light grey boundaries\n# l <- list(color = toRGB(\"grey\"), width = 0.5)\n\n# # specify map projection/options\n# g <- list(\n# showframe = FALSE,\n# showcoastlines = FALSE,\n# projection = list(type = 'Mercator')\n# )\n\n# gdpGroups = rank(gdp.xlsx$Questions$`GDP $US`)\n# reversegdpGroups = length(gdpGroups) + 1 - gdpGroups\n# df = data.frame(gdp = `GDP in Billions`, COUNTRY = gdp.xlsx$Variables$Country, CODE = UN)\n# p <- plot_geo(df) %>%\n# add_trace(\n# z = ~reversegdpGroups,\n# text = ~COUNTRY, locations = ~CODE, marker = list(line = l)\n# ) %>%\n# colorbar(title = 'GDP Rank') %>%\n# layout(\n# #title = '2014 Global GDP<br>Source:<a href=\"https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html\">CIA World Factbook</a>',\n# geo = g\n# )\n# p.3 <- config(p, displayModeBar = FALSE)\n# p.3\n# Adapted from https://plot.ly/r/choropleth-maps/\nlibrary(plotly)\nplot_geo(data.frame(GDP = length(gdp) + 1 - rank(gdp.xlsx$Questions$`GDP $US`),\n COUNTRY = gdp.xlsx$Variables$Country, CODE = UN)) %>%\n add_trace(z = ~GDP, color = ~GDP, text = ~COUNTRY, locations = ~CODE, \n marker = list(line = list(color = toRGB(\"grey\"), width = 0.5))) %>%# light grey boundaries\n colorbar(title = 'GDP Rank') %>%\n layout(geo = list(showframe = FALSE, showcoastlines = FALSE, projection = list(type = 'Mercator'))) %>%\n config(displayModeBar = FALSE)","highlightedCodeSpans":[{"start":1003,"length":3,"index":0},{"start":1019,"length":28,"index":1},{"start":1080,"length":26,"index":0},{"start":1115,"length":2,"index":1},{"start":1143,"length":3,"index":0},{"start":1157,"length":3,"index":0}],"tableTransformations":"<TabularTransformer>\r\n <TabularTransform type=\"Truncation\" truncationHeaderType=\"Column\" />\r\n <TabularTransform />\r\n</TabularTransformer>","tabularFilteringOptions":null,"hasGuiControls":false,"guiControls":{"Code":"","JSError":null,"JSErrorDetails":null,"ControlDefinitionErrors":null,"InputValidationErrors":null,"Controls":[{"ItemGuid":"00000000-0000-0000-0000-000000000000","ControlName":null,"Page":null,"Group":null,"Type":null,"Label":null,"Value":null,"Allowed":null,"EmptyListMessage":null,"Multi":false,"Prompt":null,"ErrorMessage":null,"Invalid":null,"Required":false,"AllowedTypes":null,"MinInputs":0,"MaxInputs":0,"Height":0,"Duplicates":false,"Values":null,"CheckAlign":null,"Text":null,"Increment":0.0,"Min":0.0,"Max":0.0,"Vertical":true}]},"calculating":"Idle","showDebug":false,"layout":"OutputOnly","vSplit":0.25,"hSplit":0.45,"updateWarnings":true,"updateMode":"Automatic","warnSlow":true,"Options":{"debugconsole":false,"codeposition":"OutputOnly","splitH":0.45,"splitV":0.25,"update warnings":true,"updating":"Automatic","warn slow":true}}