Import your data
data <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2022/2022-01-25/details.csv')
## Rows: 21631 Columns: 23
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): primary, description, boardgamecategory, boardgamemechanic, boardg...
## dbl (13): num, id, yearpublished, minplayers, maxplayers, playingtime, minpl...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data_small <- data %>%
select(primary, yearpublished, minplayers) %>%
filter(primary %in% c("Robin Hood", "Chaos"))
Pivoting
long to wide form
wide to long form
Separating and Uniting
Unite two columns
data_united <- data %>%
unite(col = "newName", yearpublished:minplayers, sep = "/", remove = TRUE)
Seperate a column
data_united %>%
separate(col = "newName", into = c("yearpublished", "minplayers"), sep = "/")
## # A tibble: 21,631 × 23
## num id primary description yearpublished minplayers maxplayers
## <dbl> <dbl> <chr> <chr> <chr> <chr> <dbl>
## 1 0 30549 Pandemic In Pandemi… 2008 2 4
## 2 1 822 Carcassonne Carcassonn… 2000 2 5
## 3 2 13 Catan In CATAN (… 1995 3 4
## 4 3 68448 7 Wonders You are th… 2010 2 7
## 5 4 36218 Dominion "You … 2008 2 4
## 6 5 9209 Ticket to Ride With elega… 2004 2 5
## 7 6 178900 Codenames Codenames … 2015 2 8
## 8 7 167791 Terraforming Ma… In the 240… 2016 1 5
## 9 8 173346 7 Wonders Duel In many wa… 2015 2 2
## 10 9 31260 Agricola Descriptio… 2007 1 5
## # ℹ 21,621 more rows
## # ℹ 16 more variables: playingtime <dbl>, minplaytime <dbl>, maxplaytime <dbl>,
## # minage <dbl>, boardgamecategory <chr>, boardgamemechanic <chr>,
## # boardgamefamily <chr>, boardgameexpansion <chr>,
## # boardgameimplementation <chr>, boardgamedesigner <chr>,
## # boardgameartist <chr>, boardgamepublisher <chr>, owned <dbl>,
## # trading <dbl>, wanting <dbl>, wishing <dbl>
Missing Values