When I try to upload multiple .xpt files to show the tables in the main panel of the R shiny app, it gives me the following issue.
I am also looking at the filtering option. I would like to filter by columns while uploading multiple files so that the appropriate rows in the main panel of each data frame/datatable are displayed.
Error:
Warning: Error in This kind of input is not handled
Can Someone help me for the solution?
code:
library(shiny)
library(haven)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File", multiple = TRUE,
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv", ".xpt")
),
tags$hr(),
checkboxInput("header", "Header", TRUE)
),
mainPanel(
tableOutput("contents")
)
)
)
server <- function(input, output) {
# output$contents <- renderTable({
# # input$file1 will be NULL initially. After the user selects
# # and uploads a file, it will be a data frame with 'name',
# # 'size', 'type', and 'datapath' columns. The 'datapath'
# # column will contain the local filenames where the data can
# # be found.
# inFile <- input$file1
#
# if (is.null(inFile))
# return(NULL)
#
# read.csv(inFile$datapath, header = input$header)
# })
output$contents <- renderTable({
# input$file1 will be NULL initially. After the user selects
# and uploads a file, it will be a data frame with 'name',
# 'size', 'type', and 'datapath' columns. The 'datapath'
# column will contain the local filenames where the data can
# be found.
inFile <- input$file1
if (is.null(inFile))
return(NULL)
read_xpt(inFile$datapath)
})
}
shinyApp(ui, server)
Xpt1:
STUDYID DOMAIN CR_VALUE
1 CR 1.5
2 CR 1.5
3 CR 1.5
Xpt2:
STUDYID DOMAIN CM_VALUE
1 CM 1.5
2 CM 1.8
3 CR 1.9
After filtering with the value 1.9, this is the expected output.
3 CR 1.9
