getting data from excel sheet put them as dropdowns in shiny app

I have made an shiny app where I am giving a fileInput where user can input an excel sheet like this: '

'. My code is this:


ui <- fluidPage(
  fileInput("config","Load Configuration File",accept =c('.xls',',xlsx')),
  actionButton("show_fields","Show Fields"),

server <- function(input,output) {

  x <- reactive({read_excel(input$config$datapath)})
  conf <- reactive({x() %>% column_to_rownames(., var = "Rows")})
  design <- eventReactive(input$show_fields, {
      numericInput("size","Size",value = 0),
      lapply(1:nrow(conf()),function(i) {
        selectInput(row.names(conf())[i],label = row.names(conf())[i],choices = colnames(conf()))
  output$ui <- renderUI({design()})

  mul <- eventReactive(input$estimate, {
    sapply(1:nrow(conf()), function(j) {
      conf()[row.names(conf())[j],eval(parse(text = paste0("input$",row.names(conf())[j],sep = "")))]

  output$prod <- renderText({paste("Product is: ",prod(mul(),na.rm = TRUE)*input$size)})


shinyApp(ui=ui,server = server)

when loading the xls sheet, 'Show Fields' button will show all the Rows as Drop-downs with columns as choices. So at last whatever I choose upon clicking 'Estimate' button Product will be shown of all corresponding values from excel sheet and the inputed size.

But this code is only working if I don't have different features (like U, V, W,K,L etc). You can run this code by removing rows from row 7 onwards.

So now what I want:
1: All the boxes (numericInput & selectInputs) shall come in two or three columns. The page shall look filled.
2: I want same things to happen with the actual sheet.
Here A-E,U-Z,K-O are drop-downs choices, for corresponding rows(like A-Z for Ram, Shyam etc. , U-Z for Predeep, Sudeep and K-O for Aneeta). I want each such dropdowns and whatever user selects I need to provide the product of all corresponding values from excel sheet along with given Size.

I am trying this out for many days now, and now I am frustated. Somebody please do it.

you can put excell data as data table if you want. You should add tab Panel in the mainpanel code: just lik the code below

in UI

tabPanel("Table1", DT::dataTableOutput("Table1"))

in server

   output$Table1 <- DT::renderDataTable({
            output$downloadData <- downloadHandler(
                filename = function() {
                    paste("churndata", sep=".",input$dl_data_file_type )
                content = function(file) {
                    if (input$dl_data_file_type == "xlsx")  {
                        writexl::write_xlsx(ab.churnyok, file)}
                    else if (input$dl_data_file_type == "csv"){
                        readr::write_csv(ab.churnyok, file)}})

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.