0

In this example, Shiny How to dynamically select columns of imported dataset for further analysis, they didn't give the clear ui.R and where the changes are made for dynamic select column and I cannot find clear solution. I am trying to do with shapefile, I didn't find any clear example for this. Is there any possibility for dynamic select columns of imported shapefile or for csv as well? if there is any example most appreciated

Karthik
  • 3
  • 2

1 Answers1

0

This just a general answer since you didn't provide your code, but I'll show a case where you can select from a list of choices and update the selected column reactively.

in the ui.R file you can create a dropdown of column choices with this:

fluidRow(
          column(uiOutput("columnSelect"), width = 2)
        )

then in the server.R file you have to define the outputs and dynamically call with Standard Evaluation functions:

output$columnSelect <- renderUI({
    selectInput("column", "Select column:", c('column1' , 'column2'), selected = 'column1')
  })

selectedColumn <- !! rlang::sym(input$column)

then if you have a dataframe with column1 and column2 as column names just make a call through dplyr:

dfSelectedColumn <- df %>%
  select(selectedColumn)
gizaom
  • 184
  • 8
  • `c('column1' , 'column2')` Here you are defining the column names but I have get the column dynamically from the imported shapefile which I have given. – Karthik Feb 03 '20 at 08:42
  • I got the result, I need to add 'session' word in the beginning of the server part i.e. `server <- function(session, input, output){}` – Karthik Feb 03 '20 at 15:18