Learn R Programming

googleVis (version 0.7.3)

renderGvis: renderGvis

Description

This function lets you use googleVis charts as Shiny output. Use it to wrap a googleVis-generating function that you assign to an output element in server.R; then create an htmlOutput with the same name in ui.R.

Usage

renderGvis(expr, env = parent.frame(), quoted = FALSE)

Value

Returns a function that can be assigned to a Shiny output

element.

Arguments

expr

An expression that returns a gvis object.

env

The environment in which to evaluate expr

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

Author

Joe Cheng, joe@rstudio.com

Details

More information about shiny is available online: https://shiny.posit.co/. You find further examples with googleVis on shiny on mages' blog: https://magesblog.com/tags/shiny/

Examples

Run this code
  
if (FALSE) {
# To run this example:
shiny::runApp(system.file("shiny/", package="googleVis"))
# server.R
library(googleVis)

shinyServer(function(input, output) {
  datasetInput <- reactive({
    switch(input$dataset,
           "rock" = rock,
           "pressure" = pressure,
           "cars" = cars)
  })
  
  output$view <- renderGvis({
    gvisScatterChart(datasetInput(),
                     options=list(title=paste('Data:',input$dataset)))
  })
})

# ui.R
shinyUI(pageWithSidebar(
  headerPanel("googleVis on Shiny"),
  sidebarPanel(
    selectInput("dataset", "Choose a dataset:",
                choices = c("rock", "pressure", "cars"))
  ),
  mainPanel(
    htmlOutput("view")
  )
))
}


Run the code above in your browser using DataLab