从闪亮下载列表时出错[as.data.frame.default中的错误:无法强制类'“packageIQR”'到data.frame]

时间:2018-06-11 09:56:24

标签: r shiny

我的闪亮应用程序出现了问题,无法在google或stackoverflow上找到错误的解决方案,也许我搜索不够好,但无法找到它。

下载列表时出现的错误如下:

Warning: Error in as.data.frame.default: cannot coerce class ‘"packageIQR"’ to a data.frame
Stack trace (innermost first):
    59: as.data.frame.default
    58: as.data.frame
    57: data.frame
    56: write.table
    55: eval
    54: eval
    53: eval.parent
    52: write.csv
    51: download$func 
     1: runApp

我不知道这个意思。产生此错误的代码如下:

library(shinydashboard)
library(timevis)

ui <- dashboardPage(
  dashboardHeader(title = "timevisinteractive test"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(
      box(
        title = "timeline", width = 12, status = "primary",
        timevisOutput("timeline", height = 250)
      ),

      box(
        title = "Add Item:", width = 12, status = "primary",
        textInput("id", "ID"),
        textInput("content", "New Item"),
        textInput("group", "Naam van ART"),
        dateInput("start", "Begindatum"),
        dateInput("end", "Einddatum"),
        actionButton("addBtn", "Add")
      ),

      box(title = "table",
          tableOutput("table"),
          downloadButton("downloadBtn", "Download list"))
    )
  )
)

server <- function(input, output) {

  output$timeline <- renderTimevis({
    config <- list(
      editable = TRUE,
      multiselect = TRUE
    )
    timevis(options = config)
  })

  observeEvent(input$addBtn, {
    addItem("timeline",
            data = list(id = input$id,
                        content = input$content,
                        group = input$group,
                        start = input$start,
                        end = input$end))
  })

  output$table <- renderTable({
    data <- input$timeline_data
    data
  })

  output$downloadBtn <- downloadHandler(
    filename = function() {
      paste("data.csv")
    },
    content = function(file) {
      write.csv(data(), file, row.names = FALSE)
    }
  )

}

# Run the application 
shinyApp(ui = ui, server = server)

错误发生在带有downloadbutton的服务器端,我试图在没有()的情况下编写csv,但这又产生了另一个错误。它无法将类“函数”强制转换为数据框。

提前感谢您的帮助!

0 个答案:

没有答案