playing_card: Playing cards

Description Usage Arguments Examples

View source: R/playing-cards.R

Description

Playing cards

Usage

1
2
3
4
playing_card(
  suit = c("hearts", "spades", "diamonds", "clubs"),
  value = c("a", 2:10, "j", "q", "k")
)

Arguments

suit

The name of the suit (e.g. "hearts").

value

The value (e.g. "9" for a nine).

Examples

 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
if (interactive()) {
  library(shiny)
  library(shufflecards)

  ui <- fluidPage(
    tags$h3("Playing cards"),
    fluidRow(
      column(
        width = 3,
        "King of Heart",
        playing_card("heart", "k")
      ),
      column(
        width = 3,
        "Random:",
        uiOutput("random"),
        actionButton("draw", "Draw")
      )
    )
  )

  server <- function(input, output, session) {

    output$random <- renderUI({
      input$draw
      playing_card(
        sample(c("hearts", "spades", "diamonds", "clubs"), 1),
        sample(c("a", 2:10, "j", "q", "k"), 1)
      )
    })

  }

  shinyApp(ui, server)
}

dreamRs/shufflecards documentation built on Dec. 4, 2019, 4:44 a.m.