I'm having a problem with my shiny app.
My app work with 3 elements:
-radioButtons with 3 choices ('Rachat','Reversement','Résiliation')
-fileInput to choose a csv file
-selectInput that display categories based on the categories that exists in the csv file.
My problem is that I must follow an order so that my app can work (which basically display a table and a graph),the order is: That I must choose one of the choices of the radioButtons first ,then I can choose the file and the categorie so that my table and graph can show up,if for example I choose the csv file first then I pick a choice of the radiobuttons choices nothing shows up.So please how can I solve this problem?
Here's my server function
note:
1-risque is the id of radioButtons
2-produit is the id of selectinput
3-rachat() and reversement() are 2 functions I'm using
server = function(input, output,session) {options(shiny.maxRequestSize=30*1024^5)
observeEvent(input$file, {
mytable <- read.csv(input$file$datapath, sep=";")
updateSelectInput(session,"produit", choices = unique(mytable[,"CATEGORIE"])[order(unique(mytable[,"CATEGORIE"]))])
})
output$table <- renderTable(df())
df=eventReactive(input$produit,
{
if (input$risque=='Rachat')
{
my_data<<-rachat(input$file$datapath,input$produit)[[1]]
}
if (input$risque=='Reversement')
{
my_data<<-reversement(input$file$datapath)[[1]]
}
my_data
},ignoreNULL = FALSE)
output$graphe <- renderPlot(f())
f=eventReactive(input$produit,
{
if (input$risque=='Rachat')
{
my_data<<-rachat(input$file$datapath,input$produit)[[2]]
}
if (input$risque=='Reversement')
{
my_data<<-reversement(input$file$datapath)[[2]]
}
my_data
},ignoreNULL = FALSE)
output$graphe1 <- renderPlot({
graphe(input$file1$datapath)
})