1. # read data and replace dots in names with underscores
  2. obesity = read.csv(
  3. '//www.stat.berkeley.edu/classes/s133/data/obesity.csv',
  4. stringsAsFactors = F
  5. )
  6. names(obesity) = gsub("\\.", "_", names(obesity))
  7. # add column with two letter state names and
  8. obesity = plyr::mutate(obesity,
  9. State = str_trim(State),
  10. state = state.abb[match(State, state.name)],
  11. )
  12. rCharts::choropleth(
  13. cut(Adult_Obesity_Rate, 5, labels = F) ~ state,
  14. data = obesity,
  15. pal = 'PuRd'
  16. )