In shiny application after uploading two excel files I am unable to do calculations with these uploaded files how to do that can you please help?
library(shiny)
library(readxl)
shinyUI(fluidPage({
titlePanel("Use readxl")
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Choose xlsx file1',
accept = c(".xlsx")),
fileInput('file2', 'Choose xlsx file2',
accept = c(".xlsx")),
selectInput("Analytical operation", "Operation:",
c("Add" = "add",
"Multiply" = "mult",
"Join" = "join"))
),
mainPanel(
#tableOutput('contents'),
#tableOutput('contents1'))
tabsetPanel(
tabPanel(strong("Training dataset"), tableOutput("contents"),
strong("Test dataset"),tableOutput("contents1") ),
tabPanel("Result")
)
)
)
})
)
shinyServer(function(input, output){
output$contents <- renderTable({
inFile <- input$file1
if(is.null(inFile))
return(NULL)
file.rename(inFile$datapath,
paste(inFile$datapath, ".xlsx", sep=""))
read_excel(paste(inFile$datapath, ".xlsx", sep=""), 1)
})
output$contents1 <- renderTable({
inFile1<- input$file2
if(is.null(inFile1))
return(NULL)
file.rename(inFile1$datapath,
paste(inFile1$datapath, ".xlsx", sep=""))
read_excel(paste(inFile1$datapath, ".xlsx", sep=""), 1)
})
data <- reactive({
req(input$infile1)
read_xlsx(input$infile1$datapath)
})
}
)