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