This function generates a UI component for creating a filter in a Shiny application. The filter allows users to select a column, condition, and value to filter a dataset.

create_filter(filter_id, dataset)

Arguments

filter_id

A unique identifier for the filter.

dataset

A data frame containing the dataset to be filtered.

Value

A Shiny UI component for creating a filter.

Details

The function creates a UI component with the following elements:

  • A horizontal rule (<hr>).

  • A dropdown menu for selecting a column from the dataset.

  • A dropdown menu for selecting a condition (e.g., ==, >, <, >=, <=).

  • A text input for specifying the filter value.

  • A submit button to confirm the filter.

  • A remove button to remove the filter.

Examples

if (FALSE) { # \dontrun{
  # Example usage in a Shiny app:
  ui <- fluidPage(
    create_filter("filter1", mtcars)
  )
  server <- function(input, output, session) {}
  shinyApp(ui, server)
} # }