Created
January 16, 2014 15:58
-
-
Save ramnathv/8457404 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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