I want to import 2 Rdata files into my shinyapp, then display the tables in the mainpanel, I tried the following code but it gives me a character output:
What should i add to my code to have the dataframes ? how can I allow to my app to import also csv files ?
This is my code :
server.R :
shinyServer(function(input,output){
#lecture de la table panel
panel <- reactive({
req(input$pan)
sessionEnvir <- sys.frame()
if (!is.null(input$pan)) {
p<-load(input$pan$datapath, sessionEnvir)
}
p
})
#lecture dela table achat
achats<- reactive({
req(input$achat)
sessionEnvir <- sys.frame()
if (!is.null(input$achat)){
a<-load(input$achat$datapath, sessionEnvir)
}
a
})
output$t <- renderTable(
panel()
)
output$t2 <- renderTable(
achats()
)
}
)
UI.R :
ui <- fluidPage(
titlePanel("Shiny app"),
sidebarLayout(
sidebarPanel(
#Import des tables panel et achat
fileInput("pan", label = "Import panel table",
multiple = FALSE,
buttonLabel = "Browse",
placeholder = "No file selected",
accept = c('.RData')),
fileInput("achat", label = "Import purchase table",
multiple = FALSE,
buttonLabel = "Browse",
placeholder = "No file selected",
accept = c('.RData')),
),
mainPanel(
tableOutput('t'),
tableOutput('t2'),
)
)
)
any help please ?
Thanks