Learn R Programming

g2r (version 0.1.0)

visible: Conceal & Reveal Figures

Description

Conceal & reveal figures.

Usage

conceal(proxy, figures = NULL)

reveal(proxy, figures = NULL)

Arguments

proxy

A g2r proxy as returned by g2Proxy

figures

Index of figures to apply the change to.

Examples

Run this code
# NOT RUN {
library(shiny)

ui <- fluidPage(
  actionButton("hide", "hide"),
  actionButton("show", "show"),
  g2Output("chart")
)

server <- function(input, output) {
  output$chart <- renderG2({
    g2(cars, asp(speed, dist)) %>% 
      fig_point() %>% 
      fig_line()
  })

  observeEvent(input$hide, {
    g2Proxy("chart") %>% 
      conceal()
  })

  observeEvent(input$show, {
    g2Proxy("chart") %>% 
      reveal()
  })
}

# }
# NOT RUN {
shinyApp(ui, server)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab