ggvis icon indicating copy to clipboard operation
ggvis copied to clipboard

ggvis doesn’t work together with shiny::validate

Open nr0cinu opened this issue 10 years ago • 6 comments

Hi!

let me start by saying: ggvis is coming along nicely! Awesome!

I was generating data.frames on the fly based on a dynaimc UI and ran into problems combining this with ggvis. The rest of shiny behaves nicely when input is missing thanks to validate(), but ggvis throws the error to the console when the application start, and never recovers/works. I tried wrapping ggvis into reactive/observe but that just made it worse…

A minimal example (modified from http://shiny.rstudio.com/articles/validation.html):

server <- function(input, output) {
  data <- reactive({
    validate(
      need(input$data != "none", "Please select a data set")
    )

    get(input$data, 'package:datasets')
  })

  output$table <- renderTable({
    head(data())
  })

  #mtcars %>% # Works
  data %>% # Does not
    ggvis(~mpg, ~cyl) %>%
    layer_points() %>%
    bind_shiny('plot')
}

ui <- shinyUI(fluidPage(
  titlePanel("Validation App"),

  sidebarLayout(
    sidebarPanel(
      selectInput("data", label = "Data set",
                  choices = c("none", "mtcars"))
    ),

    mainPanel(
      tableOutput("table"),
      ggvisOutput("plot")
    )
  )
))

shinyApp(ui = ui, server = server)

nr0cinu avatar Dec 18 '14 16:12 nr0cinu

Is anyone picking this issue up? This is a real blocker for using ggvis in shiny.

markriseley avatar Feb 25 '15 11:02 markriseley

Shouldn't it be data() %>%?

vzemlys avatar Feb 25 '15 11:02 vzemlys

data() %>% doesn’t help. I think the () is optional anyway when using magrittr…?

nr0cinu avatar Feb 25 '15 12:02 nr0cinu

+1 for this issue

johnpauls avatar Aug 26 '15 19:08 johnpauls

Yep just ran into this

MarkEdmondson1234 avatar Oct 15 '15 17:10 MarkEdmondson1234

ditto

joshaney avatar Nov 30 '15 21:11 joshaney