I have a created a data frame (df) and populated it with numbers in the first row in shiny R. Now I would like to see the index of each variable element of the data frame in a drop down list when I upload a file. In other words I would like to use the index to select elements rather than the column names. I know this may seem weird to ask but I really need help with this. My sample code is below:
**ui.R**
shinyUI(fluidPage(
titlePanel(""),
sidebarLayout(
sidebarPanel(
fileInput("file", "Upload the file",
accept=c('txt', 'text files', '.txt')),
tags$hr(style="padding:0px;margin:0px"),
selectInput(inputId = "table_no", label = "Select table", choices = "Pending Upload"),
),
**server.R**
shinyServer(function(input, output, session){
data <- reactive({
file1 <- input$file
if(is.null(file1)){return()}
dta <- read.csv(file1$datapath, header = TRUE, fill = TRUE)
trial <- 1:5
df <- data.frame(matrix(trial, ncol = length(trial), nrow = 1, byrow = TRUE), stringsAsFactors = FALSE)
colnames(df) <- paste("Table",trial)