【问题标题】:Using data.table in shiny application在闪亮的应用程序中使用 data.table
【发布时间】:2014-11-10 08:54:40
【问题描述】:

当我在闪亮的应用程序中使用数据表对象时出现错误。

此示例改编自 Garrett Grolemund 的这篇文章。整个闪亮的应用程序被打包成一个函数,并呈现在一个 Rmd 文件中。要重现,请将以下代码放入 R Studio 中的 .Rmd 文件中,并使用 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])
```

当我编译时,我得到这个错误:

在包中使用 data.table 时,我看到过这样的错误。但是,如果您在包中的 Imports 或 Depends 声明中包含 data.table,则该问题已得到解决(请参阅常见问题解答 6.9 http://cran.r-project.org/web/packages/data.table/vignettes/datatable-faq.pdf

这是 sessionInfo() 来自闪亮应用程序的输出

【问题讨论】:

  • 另外,对于那些花时间思考这个问题的人,我深表歉意......代码中有一些语法错误

标签: r data.table shiny


【解决方案1】:

从 data.table 1.9.4 开始,这不再是问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-08
    • 2016-02-09
    • 2020-08-27
    • 1970-01-01
    • 2016-10-23
    • 1970-01-01
    • 1970-01-01
    • 2016-12-20
    相关资源
    最近更新 更多