Skip to contents

Builds the complete 108-card UNO deck used in a standard game. Each of the four colors — red, green, blue, and yellow — includes:

  • One 0 card

  • Two copies each of cards numbered 1 through 9

  • Two copies each of the action cards: skip, reverse, and +2

Additionally, the deck includes eight uncolored wild cards:

  • Four wild cards

  • Four wild_draw4 cards

Usage

create_uno_deck()

Value

A tibble with 108 rows and 3 columns:

color

Card color — one of "red", "green", "blue", "yellow", or "wild"

value

Card face value — numbers "0" to "9", or action names

type

Card type — either "number", "action", or "wild"

Details

This function is typically used as the first step in game setup, and returns a tidy tibble containing all card data.

Examples

# Generate and inspect the deck
deck <- create_uno_deck()
dim(deck)         # Should return 108 rows, 3 columns
#> [1] 108   3
table(deck$type)  # Count of card types
#> 
#> action number   wild 
#>     24     76      8 
head(deck)        # Preview the top of the deck
#> # A tibble: 6 × 3
#>   color value type  
#>   <chr> <chr> <chr> 
#> 1 red   0     number
#> 2 red   1     number
#> 3 red   1     number
#> 4 red   2     number
#> 5 red   2     number
#> 6 red   3     number

# Filter for wild cards
deck[deck$type == "wild", ]
#> # A tibble: 8 × 3
#>   color value      type 
#>   <chr> <chr>      <chr>
#> 1 wild  wild       wild 
#> 2 wild  wild       wild 
#> 3 wild  wild       wild 
#> 4 wild  wild       wild 
#> 5 wild  wild_draw4 wild 
#> 6 wild  wild_draw4 wild 
#> 7 wild  wild_draw4 wild 
#> 8 wild  wild_draw4 wild 

# Count how many of each card value exist
table(deck$value)
#> 
#>         +2          0          1          2          3          4          5 
#>          8          4          8          8          8          8          8 
#>          6          7          8          9    reverse       skip       wild 
#>          8          8          8          8          8          8          4 
#> wild_draw4 
#>          4 

# Filter just the blue action cards
subset(deck, color == "blue" & type == "action")
#> # A tibble: 6 × 3
#>   color value   type  
#>   <chr> <chr>   <chr> 
#> 1 blue  skip    action
#> 2 blue  skip    action
#> 3 blue  reverse action
#> 4 blue  reverse action
#> 5 blue  +2      action
#> 6 blue  +2      action