Using data.table in a brilliant application

When I use a data table object in a brilliant application, I get an error.

This example is adapted from this article by Garrett Grolemmund. Where the entire brilliant application is packed into one function and displayed in the Rmd file. To play, put the following code in a .Rmd file in R Studio and compile it using ctrl-k http://shiny.rstudio.com/articles/function.html

--- runtime: shiny output: html_document --- ```{r echo = FALSE} binner <- function(var) { require(shiny) shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel(sliderInput("n", "Bins", 5, 100, 20)), mainPanel(plotOutput("hist"), htmlOutput("SessionInfo")))), server = function(input, output) { output$hist <- renderPlot(hist(var, breaks = input$n, col = "skyblue", border = "white")) output$SessionInfo <- renderText(paste(capture.output(sessionInfo()), collapse="<br>")) } ) } ``` ## Old Faithful Old faithful is known for erupting at regular intervals. But how regular are these intervals? ```{r echo = FALSE} library(data.table) faithful_dt <- as.data.table(faithful) binner(faithful_dt[ , waiting]) ``` 

When I compile, I get this error:

Shiny error

I saw such an error when using data.table in a package. However, this is fixed if you included data.table in the Import or Depends declarations in the package (see Frequently Asked Questions 6.9 http://cran.r-project.org/web/packages/data.table/vignettes/datatable-faq. pdf )

Here is the result of sessionInfo() from within a brilliant application enter image description here

+6
source share
1 answer

This is no longer a problem with data.table 1.9.4

+6
source

Source: https://habr.com/ru/post/975360/


All Articles