0

# Read file ----
df <- reactive({
 req(input$uploaded_file)
 read.csv(input$uploaded_file$datapath,
         header = input$header,
         sep = input$sep)  

 })


# dynamically allow the user to select a dependent variable ----
  output$selectbox <- renderUI({
  selectInput(inputId = "select_dev", 
            label = "Select target variable", 
            choices = names(df()))
})

# Dynamically allow the user to select their independent variables using checkboxes ----
###
###  Here is where I would like to remove the variable from the DF that they selected in output$selectbox. 
###
  output$checkbox <- renderUI({
  checkboxGroupInput(inputId = "select_var", 
                   label = "Select variables", 
                   choices = names(df()),
                   selected = names(df()))
})

|

1

0

library(shiny)

shinyApp(
  ui = fluidPage(
    uiOutput("selectbox"),
    uiOutput("checkbox")
  ),
  server = function(input, output, session) {

    df <- reactive(iris)

    output$selectbox <- renderUI({
      selectInput(inputId = "select_dev", 
                  label = "Select target variable", 
                  choices = names(df()))
    })

    output$checkbox <- renderUI({
      checkboxGroupInput(inputId = "select_var", 
                         label = "Select variables", 
                         choices = setdiff(names(df()), input$select_dev),
                         selected = setdiff(names(df()), input$select_dev))
    })
  }
)
|