Here is some code that works for me. You need to replace the variable name (var_name) with whatever variable in the dataset you want to plot.
In this code, reactive and req work together to wait for the file up be "uploaded" and then it triggers the downstream code to run.
library(shiny)
ui <- fluidPage(
fileInput('csv', 'Input CSV', accept = '.csv'),
plotOutput('hist')
)
server <- function(input, output, session) {
data <- reactive({
req(input$csv)
read.csv(input$csv$datapath)
})
output$hist <- renderPlot({
hist(data()$var_name) # replace var name
})
}
shinyApp(ui, server)