Hello i have this quite simple script i can't make to work... it give me a histogram but not for the variable i asked for ! For example when i choose the variable AGE it doesn't show the the histogram of the AGE on the population but the total population : it s very likely it selects all the column of dat instead of dat$AGE but i can't find the solution
server.R :
library(shiny)
library(ggplot2)
library(plotly)
shinyServer(function(input, output, session) {
dat <- reactive({
req(input$df)
dfile <- read.csv(input$df$datapath)
updateSelectInput(session,inputId = 'select1', label = 'Variable',
choices = colnames(dfile))
return(dfile)
})
output$data <- renderUI({
if (!is.null(input$df$datapath)){
selectInput('select1', choices = names(dat()), label = h3('Variable'))
}
})
output$plot <- renderPlotly( ggplotly(
ggplot(data=dat(),aes(x=input$select1)) + geom_histogram(stat = "count")))
})
ui.R
library(shiny)
library(ggplot2)
library(plotly)
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
fileInput("df","CSV file :"),
uiOutput("data")
),
mainPanel(
h2(plotlyOutput("plot"))
)
)
))
If you can help, i searched for this all the afternoon :3