R Shiny app 'error: Failed to parse C:/Users/user/AppData/Local/Temp/Rtmp672zUi/file2cb4f1a71c0: Invalid file, or file has unsupported features.'

I tried to create an R shiny app, to see the data from the file location, used the fileinput widget as per the code to read two different data types one in .rds and another in .sas7bdat (SAS). all is well i am able to select the type of file from the browse and view the dataset, however once i select the data type and file and move to select another data type it shows an error message when i toggle between the data types eventually i see the data both ways, but its the error message i want to remove when i toggle between the data types.

library(shiny)
library(shinyFiles)
library(admiral.test)
library(haven)
library(coler)
setwd('E:\\R')
path <- getwd()
# Define UI for application that draws a histogram
ui <- fluidPage(
  titlePanel('To select different types of data file and view there contents'),
  sidebarLayout(
    sidebarPanel(
      radioButtons('dataset','Select the data file', c(Rdataset='rda', SAS='sas7bdat')),
                   fileInput('filepath', 'File path to select the dataset',accept = '.rda')
      
    ), 
    mainPanel(
      tableOutput('table'),
      tableOutput('table2')
    )
  )
)


# Define server logic required to draw a histogram
server <- function(input, output, session) {
   output$table <- renderTable({
     if (is.null(input$filepath)) {
       return()
     } else {
       input$filepath
     }
   })
   
   table2 <- reactive({
     if (is.null(input$filepath)) {return()}
     if (!is.null(input$filepath)) {
      if (input$dataset=='rda'){
       filepath2 <- input$filepath
       filepath3 <- filepath2$datapath
       rda <- readRDS(filepath3)
       #saveRDS(rda, “x.rds”)
       return(rda)
      }} else if (is.null(input$filepath)) {return()}

     if (is.null(input$filepath)) {return()}
     if (!is.null(input$filepath)) {
    if ((input$dataset=='sas7bdat')) {
       filepath2 <- input$filepath
       filepath3 <- filepath2$datapath
       data <- haven::read_sas(filepath3)
       return(data)
    }} else if (is.null(input$filepath)) {return()}

   })
   
   output$table2 <- renderTable({
     if (is.null(input$filepath)) {return()}
     else {
             table2() }
   })
}

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



This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.