I am stuck up with one issue in R Shiny app where I am uploading an xlsx file which has data present in 8 different sheets. I did the bind_rows for all the 8 sheets and I am able to append everything into one dataframe. The issue is I am not able to see the output when I execute the Shiny app. The error I am seeing is "Error : path must be a string". Could you please help me in resolving this issue. Thank you beforehand for the clarification.
library(shiny)
library(readxl)
library(tidyverse)
library(dplyr)
# Define UI for application
ui <- fluidPage(
# Application title
titlePanel("SDV Complaince Report"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose Excel File",
multiple = FALSE,
accept = c(".xls",
".xlsx"))
),
# Show a table of the final output
mainPanel(
tableOutput("contents")
)
)
)
# Define server logic required
server <- function(input, output) {
output$contents <- renderTable({
fname <- input$file1
sheet <- excel_sheets(fname$datapath)
data_frame <- lapply(setNames(sheet, sheet),
function(x) read_excel(fname, sheet=x, col_names = F))
for(i in 1:length(data_frame)) {
data_frame[[i]]$...5 <- as.numeric(data_frame[[i]]$...5)
print(class(data_frame[[i]]$...5))
}
# attaching all dataframes together
data_frame <- bind_rows(data_frame, .id="Sheet")
})
}
# Run the application
shinyApp(ui = ui, server = server)