【发布时间】:2015-08-19 08:18:13
【问题描述】:
我刚刚将 shiny 更新到 0.12 版本并开始使用 DT 包(发现它有点难以使用但无论如何都必须这样做)。基本上我正在尝试上传或导入文件。这是我的服务器代码:
shinyServer(function(input, output, session) {
datasetInput <- reactive({
infile <- input$FileInput
if(is.null(infile))
return(NULL)
read.table(infile$datapath,header=input$header,sep=input$sep,check.names=F)
})
output$table = DT::renderDataTable(datasetInput(), server = TRUE)
})
# Also tried the following code but get the same error & warning:
# output$table <- DT::renderDataTable({
# DT::datatable(datasetInput())
# },server=TRUE)
这是我得到的错误:
Error in datatable(instance, ...) :
'data' must be either a matrix or a data frame
以及以下警告,尽管使用了server = TRUE:
Warning in run(timeoutMs) :
It seems your data is too big for client-side DataTables. You may consider server-side processing: http://rstudio.github.io/DT/server.html
我知道这是非常基本的,我找不到任何使用 DT 包从文件导入数据的示例。肯定会出现更多问题,因为我刚刚开始将所有内容从 0.11 迁移到 0.12。
【问题讨论】: