Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created February 12, 2014 23:27
Show Gist options
  • Save ramnathv/e1e04ffa03e405e36fe7 to your computer and use it in GitHub Desktop.
Save ramnathv/e1e04ffa03e405e36fe7 to your computer and use it in GitHub Desktop.
# server.R
library(shiny)
library(rCharts)
library(ggplot2)
data(uspop2000, package = 'leaflet')
base_df <- head(uspop2000[which(uspop2000$State == "AL"), ])
shinyServer(function(input, output){
output$myChart1 <- renderPlot({
pop_plot <- ggplot(base_df, aes(x = City, y = Pop2000)) +
geom_bar(stat = "identity")
print(pop_plot)
})
output$myChart2 <- renderMap({
map3 <- Leaflet$new()
map3$setView(c(37.45, -93.85), zoom = 5)
map3$marker(c(37.45, -93.85), bindPopup = "Hi. I am a popup")
map3$marker(c(37.45, -93.85), bindPopup = "Hi. I am another popup")
map3
})
})
# ui.R Version that doesn't work
library(shiny)
library(rCharts)
library(ggplot2)
library(leaflet)
shinyUI(pageWithSidebar(
headerPanel("test"),
sidebarPanel(),
mainPanel(
tabsetPanel(
tabPanel("map2", showOutput('myChart2', 'leaflet')),
tabPanel("test", plotOutput("myChart1"))
)
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment