-2

I have an excel sheet like excel_screenshot. I want the row names(Ram, Shyam, etc) as select input in my shiny App with colnames (A,B,C,D,E) as their choices. Also as the user selects any value for any variable name, I want to set the corresponding value to that variable in the back end.

For example, I have the drop-down named "Ram", If the user selects 'B' in Ram them I want- Ram <- 2.4

Lin Du
  • 88,126
  • 95
  • 281
  • 483

1 Answers1

0

Since you didn't provide any code to work with or explain your specific situation, I took some liberties and assumptions.

Here is the code, as you change the dropdowns you will see the Print statement change accordingly.

ui <- fluidPage(

  # App title ----
  titlePanel("Hello Shiny!"),

    # Main panel for displaying outputs ----
    mainPanel(

      selectInput("Input_Ram", "Ram:",
                  c("A","B","C","D")
      ),
      selectInput("Input_Shyam", "Shyam:",
                  c("A","B","C","D")
      ),
      selectInput("Input_GhanShyam", "GhanShyam:",
                  c("A","B","C","D")
      ),
      selectInput("Input_MastRam", "MastRam:",
                  c("A","B","C","D")
      ),

      # Output: selections ----
      verbatimTextOutput("values")
  )
)

server <- function(input, output) {

  data <- data.frame(RowNames = c("Ram","Shyam","GhanShyam","MastRam"), A = c(1.3,3.2,1,8.4), B= c(2.4,3,0.6,4.5), C = c(3,1,2.3,1.7), D = c(1.6,3.4,5,1.9), stringsAsFactors = FALSE)

  Ram_Dat <- reactive({
    data[[input$Input_Ram]][1]
    })

  Shyam_Dat <- reactive({
    data[[input$Input_Shyam]][1]
    })

  GhanShyam_Dat <- reactive({
    data[[input$Input_GhanShyam]][1]
    })

  MastRam_Dat <- reactive({
    data[[input$Input_MastRam]][1]
    })

  output$values <- renderPrint({
    paste0("Ram: ", Ram_Dat(), " Shyam: ", Shyam_Dat(), " GhanShyam: ", GhanShyam_Dat(), " MastRam: ", MastRam_Dat())

  })


}

shinyApp(ui, server)
Kevin
  • 1,974
  • 1
  • 19
  • 51
  • You have hard-coded every thing. User will upload this excel sheet. Rows and column names can be anything. I am providing a fileInput where user will upload the excel sheet, from where I have to make ui dynamically. – Pallav Gupta Dec 12 '19 at 06:09
  • You need to provide a reproducible example / describe that in your problem statement. – Kevin Dec 12 '19 at 12:27
  • @Kevin can you help with this https://stackoverflow.com/questions/59431981/how-to-create-two-independent-drill-down-plot-using-highcharter – John Smith Dec 21 '19 at 12:57