Skip to content

Instantly share code, notes, and snippets.

@mages
Last active December 13, 2015 20:38
Show Gist options
  • Save mages/4970975 to your computer and use it in GitHub Desktop.
Save mages/4970975 to your computer and use it in GitHub Desktop.
Example of renderGvis by Joe Cheng
# Contributed by Joe Cheng, February 2013
# Requires googleVis version 0.4.0 and shiny 0.4.0 or higher
# server.R
library(googleVis)
library(shiny)
shinyServer(function(input, output) {
datasetInput <- reactive({
switch(input$dataset,
"rock" = rock,
"pressure" = pressure,
"cars" = cars)
})
output$view <- renderGvis({
gvisScatterChart(datasetInput(), options=list(width=400, height=450))
})
})
# ui.R
shinyUI(pageWithSidebar(
headerPanel("Example 1: scatter chart"),
sidebarPanel(
selectInput("dataset", "Choose a dataset:",
choices = c("rock", "pressure", "cars"))
),
mainPanel(
htmlOutput("view")
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment