简体   繁体   中英

failed to display variable data types in shiny flexdashboard

I am trying to display variable types dynamically and my code is something like this (using into flexdashboard shiny app):

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")

I read the csv file from fileInput method.

The result is expected something what we get when do str(DF) in R but what I am getting is datatables htmlwidget as output.

Not sure what I have done wrong here, need to understand the correct method.

Here's what you need -

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM