Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created January 16, 2014 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramnathv/8457404 to your computer and use it in GitHub Desktop.
Save ramnathv/8457404 to your computer and use it in GitHub Desktop.
RpresDataMaps
========================================================
author: Ramnath Vaidyanathan
date:
DataMaps
========================================================
```{r tidy = F}
# read data and replace dots in names with underscores
obesity = read.csv(
'http://www.stat.berkeley.edu/classes/s133/data/obesity.csv',
stringsAsFactors = F
)
names(obesity) = gsub("\\.", "_", names(obesity))
# add column with two letter state names and
obesity = plyr::mutate(obesity,
State = stringr::str_trim(State),
state = state.abb[match(State, state.name)],
)
r1 <- rCharts::choropleth(
cut(Adult_Obesity_Rate, 5, labels = F) ~ state,
data = obesity,
pal = 'PuRd'
)
```
Map
====
```{r results = 'asis', comment = NA}
r1$show('iframesrc', cdn = TRUE)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment