对于我的应用程序,我要求用户上传差异数据集。我希望与这些对象一起进行一些工作,例如将它们组合并修改(基本操作)。
我当时在考虑反应性功能,但我不知道如何实现它们
library(readxl)
ui <- fluidPage(
titlePanel("Uploading Files"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Upload 'Contract revenues' (xlsx)",
multiple = TRUE,
accept = c(".xlsx")),
tags$hr(),
fileInput("file2", "Upload 'Mapping Service' (xlsx)",
multiple = TRUE,
accept = c(".xlsx")),
tags$hr()
),
mainPanel(
tableOutput("contents")
)
)
)
server <- 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$content <- renderTable({
inFile2 <- input$file2
if(is.null(inFile2))
return(NULL)
file.rename(inFile2$datapath,
paste(inFile2$datapath, ".xlsx", sep=""))
read_excel(paste(inFile2$datapath, ".xlsx", sep=""), 1)
})
}
shinyApp(ui, server)