I'm trying to make an interface in Shiny of R, the idea is to select a .csv file, when reading it take the columns and put them in a drop-down list
I have tried it in several ways, at the moment it seems that it reads the file, but it does not update the drop-down list, any idea of what is happening?
library(shiny)
library(shinythemes)
ui = fluidPage(
theme = shinytheme("flatly"),
navbarPage(theme = "flatly","Analisis de Datos",
tabPanel("Analisis Exploratorio")),
sidebarPanel(
fileInput("archivo", "Escoger archivo CSV",multiple = TRUE, accept =
c("text/csv","text/comma-separated-values,text/plain",".csv")),
tabPanel("Histograma",
selectInput("columnas", "Seleccionar Columna", choices= NULL))))
server <-function(input, output , session) {
Datos <- reactive({
inFile <- input$archivo
req(inFile)
# Leyendo el csv
df <- read.csv(input$archivo$datapath,header = TRUE,sep =',',quote = '"')
#Nombre de las columnas
variables <- names(df)
updateSelectInput(session, "columnas", "Seleccionar Columna", choices =
variables)
return(df)
})
}
shinyApp(ui = ui, server = server)