library(rlist)
#' Group Cards By Value
#'
#' @param cards A list of objects from the S4 class 'card'.
#'
#' @return A list of lists. Each element of the output is a group of cards
#' sharing the same value.
#' @export
#' @importFrom rlist list.append
#'
#' @examples
group_cards <- function(cards){
n <- length(cards)
values <- c()
card_groups <- list()
for ( i in 1:n){
values <- c(values,cards[[i]]@value)
}
names(values) <- paste(1:n)
values <- sort(values)
count <- 0
for (i in 13:1){
select_value <- values[values == i]
select_cards <- select_value %>% names() %>% as.numeric() %>% cards[.]
if (length(select_cards) != 0) card_groups %<>% list.append(select_cards)
}
return(card_groups)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.