Difficulties creating a shinyapp with simple user CSV upload button, and simple diagram output display

Dear all,

I hope you are all doing well! I am very new to this community and to Rstudio in general.
I really enjoy using R and Shiny, but find some difficulties reaching my objective.

My use case is, I believe, very simple. I want a user to be able to upload a CSV file containing a few thousands lines and a few columns (let's say only two columns so far, one entitled "sexe", corresponding to the individual's gender, and the other entitled "SISEDisc", corresponding to the individual's choosen graduate discipline).
Once uploaded, I want the user to be able to get a few simple diagrams (variable proportions generated from those two columns - see code below).
I have managed so far to get on one side a working upload button for my file, and on the other side, working diagrams using the CSV file after having imported it in RStudio's dataset. Unfortunately, I didn't yet find a way to get both functions working together in the same shinyapp: user upload function and then diagram display from the uploaded CSV.

The code I have worked on so far looks like this:


ui <- fluidPage(
            fileInput("file1", "Choose CSV File",
                      accept = c(
            checkboxInput("header", "Header", TRUE)
            h1("Women-Men Balance"),
            h1("Balance by discipline"),
            h1("Women by Discipline"),

server <- function(input, output, session) {
    Genre <- eventReactive(input$file, {

    output$diagramsexe <- renderPlot({
        table_sexe <- table(Genre$sexe)
        table_sexeprop <- prop.table(table_sexe)
    output$diagramsexedisc <- renderPlot({
        table_discXsexe <- table(Genre$sexe,Genre$SISEDisc)
        table_discXsexe_prop <- prop.table(table_discXsexe)

    output$diagramsexedisconlyF <- renderPlot({
        table_discXsexeinv <- table(Genre$SISEDisc,Genre$sexe)
        table_discXsexe_prop_onlyF <- table_discXsexeinv[,c("F")]  

shinyApp(ui, server)


I would really really appreciate if you could help me.
Thank you so much in advance!

I can of course give more details on the use case.
I hope my message is clear enough, it's my first one in here I hope I can improve.

If you make a reactive ...

myreactive <- reactive ({  etc...

When you want to use its content you must access it as though it were a function, I.e. with brackets.

output$something <-renderWhatever({
  myr <- req(myreactive())
1 Like

Thank you very much! I will try this.