Action button to filter on user submitted data within app

Hi,

Right now I have created a series of functions that allow me to input certain elements into RStudio as a list

> saveData <- function(data) {
>   data <- as.data.frame(t(data))
>   if (exists("responses")) {
>     responses <<- rbind(responses, data)
>   } else {
>     responses <<- data
>   }
> }
> 
> loadData <- function() {
>   if (exists("responses")) {
>     responses
>   }
> }

After creating and inputting this data, I would like to be able to actually filter down on it on a seperate tab, with a command similar to

>  formData <- reactive({
>     data <- sapply(fields, function(x) input[[ ]])
>     data
>   })
>   
>   # When the Submit button is clicked, save the form data
>   observeEvent(input$submit, {
>     saveData(formData())
>   })
>   
>   # Show the previous responses
>   # (update with current response when Submit is clicked)
>   output$responses <- DT::renderDataTable({
>     input$submit
>     loadData()
>     responses <- as_tibble(responses)
>     
>   })
>   ###
>   
>   
>     filtered <- reactive({
>       responses <- as_tibble(responses)
>       responses %>%
>       filter(responses$year == input$year)
>       responses <- as_tibble(responses)
>       
>   })
>   output$Info <- DT::renderDataTable({
>     input$submit1
>     filtered
>   })

*Imagine that for simplicity purposes, one of the user inputs I have is year, and I'd like to be able filter down through a selectInput and submit statement that would show me all rows with a specific year.

However I cannot even seem to get a grasp on what I am doing wrong or where I would start. Does anyone have any idea if it'd even be possible to filter down on data that is technically an 'input' and also part of your 'output' within Shiny?

Thanks

----update----

Boy, I feel stupid. I realized my mistake and that it's not hard to filter down on the "response" object I created by just using subsetting and inputting seperate parameter values to equal my original objects columns names. I guess the main question I have now would be how to create an action button that would initiate the filtering all at once, so you could enter all parameters, hit submit, then have the data table update accordingly

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.