无法在闪亮的 flexdashboard 中显示可变数据类型

failed to display variable data types in shiny flexdashboard

我正在尝试动态显示变量类型,我的代码是这样的(用于 flexdashboard 闪亮的应用程序):

tblCls <- reactive({
    req(input$file1)
    inFile <- input$file1
    if (is.null(inFile)){
      return(NULL)
    }else{
     datatable(head(read.csv(inFile$datapath, header = input$header), 5))

    }
})

output$class <- renderText({
    print(class( tblCls()  ))
  })

textOutput("class")

我从 fileInput 方法读取了 csv 文件。

结果是我们在 R 中执行 str(DF) 时得到的结果,但我得到的是 datatables htmlwidget 作为输出。

不知道我这里做错了什么,需要了解正确的方法。

这是您需要的 -

tblCls <- reactive({
   req(input$file1) # if else not needed when using req()
   head(read.csv(input$file1$datapath, header = input$header), 5)
})

output$class <- renderPrint({
   str(tblCls())
})

textOutput("class")