How to print selected values โ€‹โ€‹from checkboxGroupInput for debug target in R Shiny?

I am trying to create an application whose ultimate goal is to select rows of a matrix that satisfies some user-selected condition using Shiny ( checkboxGroupInput, sliderInput, etc

) elements For example, consider data that is part of a file global.R

:

global.R

data <- t(combn(20, 5))  # 20 has been chosen for simplicity. In reality is a variable selected from c(20, 30, 45).

      

In ui.R

and server.R

I created a set checkboxGroupInput

to reflect a range c(1:20)

from which the user can select some numbers.

ui.R

....
uiOutput(outputId = "numSelector")
....

      

server.R

     ....... 
     output$numSelector <- renderUI({
        out <- checkboxGroupInput(
            inputId = "numSelector",
            label   = "Select the numbers",
            choices = selectRange(input$dataName),
            inline = TRUE
        )
        return(out)
    })
   ........

      

For debugging purposes, I would like to print the selected values โ€‹โ€‹with checkboxGroupInput

(or any other Shiny elements) and filter the rows data

based on those values. Any suggestion?

+3


source to share


1 answer


Using the code above, you can call a vector of values โ€‹โ€‹selected with input$numSelector

. They can be passed to a dataframe for filtering or any other shiny output object.

Print values:

print(input$numSelector)

      



Filter

data[data$dataName %in% input$numSelector,]

      

To run this print code, it will need to be placed in the watch () function.

+4


source







All Articles