ggvis
ggvis copied to clipboard
ggvis doesn’t work together with shiny::validate
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)
Is anyone picking this issue up? This is a real blocker for using ggvis in shiny.
Shouldn't it be data() %>%
?
data() %>%
doesn’t help. I think the ()
is optional anyway when using magrittr…?
+1 for this issue
Yep just ran into this
ditto