Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactivity is now broken with data.table #1696

Closed
raubreywhite opened this issue May 8, 2017 · 5 comments
Closed

Reactivity is now broken with data.table #1696

raubreywhite opened this issue May 8, 2017 · 5 comments

Comments

@raubreywhite
Copy link

@raubreywhite raubreywhite commented May 8, 2017

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.

@wch

This comment has been minimized.

Copy link
Collaborator

@wch wch commented May 8, 2017

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()
    })

  }
)
@raubreywhite

This comment has been minimized.

Copy link
Author

@raubreywhite raubreywhite commented May 8, 2017

Interesting... Do you have any suggestions on where I should repost it? flexdashboard, probably?

@wch

This comment has been minimized.

Copy link
Collaborator

@wch wch commented May 8, 2017

Here's a a simplified Rmd example that gives the same error, object 'x' not found:

---
title: "data.table test"
runtime: shiny
---

```{r}
library(data.table)
library(shiny)

getData <- reactive({
  data <- data.table(x=1:10, y=1:10)
  data[x==1]
})
```


```{r}
renderTable(getData())
```

```{r}
renderPrint({
  str(getData())
})
```

```{r}
# This works OK
data2 <- data.table(x=1:10, y=1:10)
data2[x==1]
```

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.

mattdowle added a commit to Rdatatable/data.table that referenced this issue Jun 2, 2017
@mattdowle

This comment has been minimized.

Copy link

@mattdowle mattdowle commented Jun 2, 2017

Thanks for reporting. Should be resolved now. Please test and close.
https://github.com/Rdatatable/data.table/wiki/Installation#install-datatable-development-version

@wch

This comment has been minimized.

Copy link
Collaborator

@wch wch commented Jun 2, 2017

Looks like it works!

@wch wch closed this Jun 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.