Code for this example is available here.
knitr::opts_chunk$set(echo = FALSE) library(shufflecards) library(shiny)
GitHub repo : https://github.com/dreamRs/shufflecards
deck <- expand.grid( suits = c("hearts", "spades", "diamonds", "clubs"), values = c("a", 2:10, "j", "q", "k") ) deck$order <- as.numeric(deck$values)
rmd_group_buttons( shuffleId = "grid", label = "Click to sort cards !", arrange_button("Sort by value", "cardVal", icon = icon("sort-numeric-asc")), arrange_button("Sort by value (decreasing)", "cardVal", desc = TRUE, icon = icon("sort-numeric-desc")), arrange_button("Sort by suits", "cardSuits", icon = icon("sort-alpha-asc")), arrange_button("Random!", "random", icon = icon("random")) )
shuffle_widget( shuffleId = "grid", no_card = "No card to display!", card_list = lapply( X = seq_len(nrow(deck)), FUN = function(i) { shuffle_card( cardVal = deck[i, "order"], # for sorting cardSuits = deck[i, "suits"], # for sorting playing_card(deck[i, "suits"], deck[i, "values"]) ) } ) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.