Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReactivity is now broken with data.table #1696
Comments
|
It works in a normal Shiny app, so this is probably specific to Shiny + Rmd documents: library(data.table)
library(shiny)
shinyApp(
ui = fluidPage(
tableOutput("tbl")
),
server = function(input, output) {
getData <- reactive({
data <- data.table(x=1:10,y=1:10)
data[x==1]
})
output$tbl <- renderTable({
getData()
})
}
) |
|
Interesting... Do you have any suggestions on where I should repost it? flexdashboard, probably? |
|
Here's a a simplified Rmd example that gives the same error,
I think there's probably some issue with the non-standard evaluation of the code in the reactive. For some reason it happens only with a Shiny doc, but not in a regular Shiny app. |
|
Thanks for reporting. Should be resolved now. Please test and close. |
|
Looks like it works! |
This has been brought up in data.table as well (Rdatatable/data.table#2001)
These examples all use this framework: http://rmarkdown.rstudio.com/flexdashboard/
So you need to rename "failingFlexdashboard.txt" to "failingFlexdashboard.Rmd" and then you can run it (the same with "workingFlexdashboard.txt" -> "workingFlexdashboard.Rmd").
I've also attached the log from my shiny server that gives the error.
Basically, when the reactive data contains a data.table instance, it fails. When the reactive data contains a data.frame instance, it works.
test_error-docker-20170508-120846-37265 (linux's conflicted copy 2017-05-08) (linux's conflicted copy 2017-05-08) copy.txt
failingFlexdashboard.txt
workingFlexdashboard.txt
Basically, Shiny seems to be trying to treat it as a data.frame, not a data.table, so it can't find the variable to stratify on.