gpt4 book ai didi

r - 在 Shiny 的应用程序中使用 data.table

转载 作者:行者123 更新时间:2023-12-04 12:36:06 26 4
gpt4 key购买 nike

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

此示例改编自 Garrett Grolemund 的这篇文章。整个 Shiny 的应用程序被打包成一个函数,并呈现在一个 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])
```

当我编译时,我收到此错误:

Shiny Error

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

这是 sessionInfo() 的输出从 Shiny 的应用程序内部
enter image description here

最佳答案

这不再是 data.table 1.9.4 的问题

关于r - 在 Shiny 的应用程序中使用 data.table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25871622/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com