Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Last active January 2, 2016 06:29
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramnathv/8264301 to your computer and use it in GitHub Desktop.
Save ramnathv/8264301 to your computer and use it in GitHub Desktop.
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)],
)
library(shiny)
library(rMaps)
shinyServer(function(input, output, session){
output$mychoro = renderChart2({
choropleth(
cut(Adult_Obesity_Rate, 5, labels = F) ~ state,
data = obesity,
pal = input$mypal
)
})
})
library(shiny)
library(rMaps)
shinyUI(pageWithSidebar(
headerPanel('Datamaps with Shiny'),
sidebarPanel(
selectInput('mypal', 'Palette', c('PuRd', 'Blues'))
),
mainPanel(
chartOutput('mychoro', 'datamaps')
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment