I am trying to add a dynamic ggvis graph to a Shiny app. First, the user selects a dimension, and then adds elements from this dimension.
For global .R and sample data, see https://gist.github.com/tts/a41c8581b9d77f131b31
server.R:
shinyServer(function(input, output, session) {
ui.R:
shinyUI(fluidPage( titlePanel('Some (alt)metric data for articles published since 2010'), sidebarLayout( sidebarPanel( selectInput( inputId = "dim", label = "Dimension", choices = dimensions, selected = c("Title")), uiOutput("items") ), mainPanel( tabsetPanel(
This is normal
- at the beginning when there are no elements and all data is displayed. This is a hack because the ggvis object throws an error if there is no data being served.
- when all selected items are deleted (which matches 1.), and another dimension is selected
But when I try to switch to another dimension without first deleting the elements, I get the following:
Error in `$<-.data.frame`(`*tmp*`, "keys", value = c(1L, 0L)) : replacement has 2 rows, data has 0
I understand that ggvis is very new and constantly evolving, but I suspect there is something in the Shiny reactions that are not synchronized. If anyone can point out what I'm doing wrong, thank you very much!
source share