Last active
January 2, 2016 06:29
-
-
Save ramnathv/8264301 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
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)], | |
) |
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
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 | |
) | |
}) | |
}) |
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
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