I've tried this probably 10 different ways and the best I can do is get "name" "id" and "class" to show up in my selectinput columns once I upload a .csv.
How do I get my uploaded data's column names to populate the selectInput choices?
Here's the relevant UI and Server Code I'm working with. Forgive my ignorance, I'm just diving into Shiny for the first time.
shinyUI(
fluidPage(fluidRow(
theme = bs_theme(version = 4, bootswatch = "minty"),
# Application title
titlePanel("Test"),
h4("Test"),
mainPanel(width=750,
# File Upload
fileInput("file1", "Choose CSV File (WILL ONLY GIVE YOU A SUMMARY rn)",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv"))),
tabsetPanel(type="tab",
tabPanel("Summary",
varSelectInput(inputId = "VarX", label="Select", data = tableOutput("selectfile")
))
))`
# ------------------------------------------------------------------
shinyServer(function(input, output) {
rawData <- eventReactive(input$file1, {
read.csv(input$file1$datapath)
})
datacolumns<- eventReactive(input$file1{
if(is.null(input$file1)) {return()}
df<-read.csv(input$file1$datapath)
df
})
output$selectfile<-renderTable({
datacolumns()
})
I am trying to get the user uploaded data's column names to populate the selectinput choices.