Skip to content

Instantly share code, notes, and snippets.

@kawasaki2013
Created November 19, 2018 16:46
Show Gist options
  • Select an option

  • Save kawasaki2013/4c4e17173055408bce5d07641075c6ca to your computer and use it in GitHub Desktop.

Select an option

Save kawasaki2013/4c4e17173055408bce5d07641075c6ca to your computer and use it in GitHub Desktop.
highcharter を使う
library(tidyverse) # data manipulation and visualization
library(gapminder) # data
library(countrycode) # visualization
library(highcharter) # visualization
foo <- gapminder %>%
+ filter(year == 2007) %>%
+ mutate(iso3 = countrycode(country, origin = "country.name", destination = "iso3c"))
highchart() %>%
+ hc_add_series_map(worldgeojson, foo, value = 'lifeExp', joinBy = 'iso3') %>%
+ hc_title(text = 'Life expectancy in 2007') %>%
+ hc_colorAxis(minColor = "#ffdf3f", maxColor = "#5c46ff", min = min(foo$lifeExp), max = max(foo$lifeExp)) %>%
+ hc_tooltip(useHTML = TRUE, headerFormat = "", pointFormat = "{point.country}: {point.lifeExp} years")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment