Description Usage Arguments Examples
Use in a Shiny app to filter cards.
1 2 3 4 5 | filter_cards_groups(
shuffleId,
groups,
session = shiny::getDefaultReactiveDomain()
)
|
shuffleId |
The id of the shuffle container. |
groups |
Groups (defined in |
session |
The |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | if (interactive()) {
library(ggplot2)
library(shiny)
library(shufflecards)
# utility fun
is.even <- function(x) x %% 2 == 0
ui <- fluidPage(
tags$h2("Filter a Shuffle Grid By Groups"),
fluidRow(
column(
width = 3,
radioButtons(
inputId = "type_num",
label = "Odd or Even",
choices = c("All", "Odd", "Even")
)
),
column(
width = 9,
shuffle_container(
shuffleId = "gridNum",
card_list = lapply(
X = 1:12,
FUN = function(i) {
shuffle_card(
groups = ifelse(is.even(i), "even", "odd"),
plotOutput(
outputId = paste0("plot", i),
width = "250px",
height = "250px"
)
)
}
)
)
)
)
)
server <- function(input, output, session) {
# Make individual plots ----
lapply(
X = 1:12,
FUN = function(i) {
output[[paste0("plot", i)]] <- renderPlot({
ggplot() + geom_text(aes(1, 1, label = i), size = 50)
})
}
)
# Filters ----
observe({
if (input$type_num == "All") {
type_num <- c("even", "odd")
} else {
type_num <- tolower(input$type_num)
}
# Pass a vector of groups to display
filter_cards_groups("gridNum", type_num)
})
}
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.