Introduction

The goal of this task is to select a dataset from a web source and utilize TidyVerse packages to create a programming vignette. This vignette aims to demonstrate the use of one or more features provided by the TidyVerse package in combination with the chosen dataset.

Data Acquisition

Input file:"best_selling_switch_games.csv” from

https://github.com/ZIXIANNOW/DATA607Tidyverse/blob/main/best_selling_switch_games.csv

Source:https://www.kaggle.com/datasets/kabhishm/best-selling-nintendo-switch-video-games

url <- 'https://raw.githubusercontent.com/ZIXIANNOW/DATA607Tidyverse/main/best_selling_switch_games.csv'
database <- read_csv(url)
## Rows: 73 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (4): title, genre, developer, publisher
## dbl  (1): copies_sold
## date (2): as_of, release_date
## 
## ℹ 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.
kbl(database) %>%
  kable_paper() %>%
  scroll_box(width = "100%", height = "400px")
title copies_sold genre developer publisher as_of release_date
Mario Kart 8 Deluxe 48410000 Kart racing Nintendo EPD Nintendo 2022-09-30 2017-04-28
Animal Crossing: New Horizons 40170000 Social simulation Nintendo EPD Nintendo 2022-09-30 2020-03-20
Super Smash Bros. Ultimate 29530000 Fighting Bandai Namco StudiosSora Ltd.  Nintendo 2022-09-30 2018-12-07
The Legend of Zelda: Breath of the Wild 27790000 Action-adventure Nintendo EPD Nintendo 2022-09-30 2017-03-03
Pokémon Sword and Shield 25370000 Role-playing Game Freak The Pokémon CompanyNintendo 2022-09-30 2019-11-15
Super Mario Odyssey 24400000 Platformer Nintendo EPD Nintendo 2022-09-30 2017-10-27
Super Mario Party 18350000 Party NDcube Nintendo 2022-09-30 2018-10-05
Pokémon Brilliant Diamond and Shining Pearl 14920000 Role-playing ILCA The Pokémon CompanyNintendo 2022-09-30 2021-11-19
Ring Fit Adventure 14870000 Exergamerole-playing Nintendo EPD Nintendo 2022-09-30 2019-10-18
Pokémon: Let’s Go, Pikachu! and Let’s Go, Eevee! 14810000 Role-playing Game Freak The Pokémon CompanyNintendo 2022-09-30 2018-11-16
Pokémon Legends: Arceus 13910000 Action role-playing Game Freak The Pokémon CompanyNintendo 2022-09-30 2022-01-28
New Super Mario Bros. U Deluxe 13310000 Platformer Nintendo EPD Nintendo 2022-03-31 2019-01-11
Splatoon 2 13300000 Third-person shooter Nintendo EPD Nintendo 2022-03-31 2017-07-21
Luigi’s Mansion 3 11430000 Action-adventure Next Level Games Nintendo 2022-03-31 2019-10-31
Pokémon Scarlet and Violet 10000000 Role-playing Game Freak The Pokémon CompanyNintendo 2022-11-20 2022-11-18
Super Mario 3D World + Bowser’s Fury 9430000 Platformer Nintendo EPD Nintendo 2022-03-31 2021-02-12
Super Mario 3D All-Stars 9070000 Platformercompilation Nintendo Nintendo 2021-12-31 2020-09-18
Mario Party Superstars 8070000 Party NDcube Nintendo 2022-09-30 2021-10-29
Splatoon 3 7900000 Third-person shooter Nintendo EPD Nintendo 2022-09-30 2022-09-09
Super Mario Maker 2 7890000 PlatformerLevel editor Nintendo EPD Nintendo 2021-12-31 2019-06-28
Monster Hunter Rise 7700000 Action role-playing Capcom Capcom 2021-12-31 2021-03-26
Nintendo Switch Sports 6150000 Sports Nintendo EPD Nintendo 2022-09-30 2022-04-29
The Legend of Zelda: Link’s Awakening 6080000 Action-adventure Grezzo Nintendo 2021-12-31 2019-09-20
Kirby and the Forgotten Land 5270000 Platformer HAL Laboratory Nintendo 2022-09-30 2022-03-25
Mario Tennis Aces 4280000 Sports Camelot Software Planning Nintendo 2021-12-31 2018-06-22
Clubhouse Games: 51 Worldwide Classics 4220000 Tabletop game NDcube Nintendo 2022-03-31 2020-06-05
Donkey Kong Country: Tropical Freeze 4120000 Platformer Retro Studios Nintendo 2021-12-31 2018-05-04
Hyrule Warriors: Age of Calamity 4000000 Hack and slash Omega Force .mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}JP: Koei TecmoNA/PAL: Nintendo 2022-01-04 2020-11-20
Kirby Star Allies 3980000 Platformer HAL Laboratory Nintendo 2021-12-31 2018-03-16
The Legend of Zelda: Skyward Sword HD 3910000 Action-adventure Tantalus Media Nintendo 2022-03-31 2021-07-16
Fire Emblem: Three Houses 3820000 Tactical role-playing Intelligent SystemsKoei Tecmo Nintendo 2021-12-31 2019-07-26
1-2-Switch 3630000 Party Nintendo EPD Nintendo 2021-12-31 2017-03-03
Momotaro Dentetsu: Showa, Heisei, Reiwa Mo Teiban! 3500000 Board game Konami JP: Konami 2022-03-22 2020-11-19
Paper Mario: The Origami King 3340000 Role-playingaction-adventure Intelligent Systems Nintendo 2021-12-31 2020-07-17
Minecraft 3310000 Sandboxsurvival Mojang JP: Xbox Game StudiosNA/PAL: Mojang 2022-10-22 2017-05-11
Among Us 3200000 Partysocial deduction Innersloth Innersloth 2020-12-31 2020-12-15
Yoshi’s Crafted World 3010000 Platformer Good-Feel Nintendo 2021-12-31 2019-03-29
Metroid Dread 2900000 Action-adventure MercurySteamNintendo EPD Nintendo 2022-03-31 2021-10-08
New Pokémon Snap 2740000 Photography Bandai Namco Studios JP: The Pokémon CompanyNA/PAL: Nintendo 2022-05-15 2021-04-30
Arms 2660000 Fighting Nintendo EPD Nintendo 2021-12-31 2017-06-16
Xenoblade Chronicles 2 2440000 Action role-playing Monolith Soft Nintendo 2021-12-31 2017-12-01
Mario Golf: Super Rush 2350000 Sports Camelot Software Planning Nintendo 2022-03-31 2021-06-25
Pikmin 3 Deluxe 2230000 Real-time strategypuzzle Nintendo EPDEighting Nintendo 2021-12-31 2020-10-30
Mario Strikers: Battle League 2170000 Sports Next Level Games Nintendo 2022-09-30 2022-06-10
Octopath Traveler 2160000 Role-playing Square EnixAcquire JP: Square EnixNA/PAL: Nintendo 2022-01-02 2018-07-13
Captain Toad: Treasure Tracker 2130000 Action puzzle Nintendo EPD Nintendo 2021-12-31 2018-07-13
Dragon Ball FighterZ 2010000 Fighting Arc System Works Bandai Namco Entertainment 2021-12-31 2018-09-27
Mario + Rabbids Kingdom Battle 2000000 Tactical role-playing Ubisoft ParisUbisoft Milan NA/PAL: UbisoftJP/KOR: Nintendo[18] 2018-09-02 2017-08-29
Pokémon Mystery Dungeon: Rescue Team DX 1890000 Roguelike Spike Chunsoft Nintendo 2021-12-31 2020-03-06
Taiko no Tatsujin: Drum ‘n’ Fun! 1890000 Rhythm Bandai Namco Studios Bandai Namco Entertainment 2021-12-31 2018-07-19
Xenoblade Chronicles 3 1720000 Action role-playing Monolith Soft Nintendo 2022-09-30 2022-07-29
Miitopia 1680000 Role-playing Grezzo Nintendo 2022-03-31 2021-05-21
Xenoblade Chronicles: Definitive Edition 1680000 Action role-playing Monolith Soft Nintendo 2021-12-31 2020-05-29
Big Brain Academy: Brain vs. Brain 1590000 Puzzle Nintendo EPD Nintendo 2022-03-31 2021-12-03
Mario Kart Live: Home Circuit 1580000 Kart racingaugmented reality Velan Studios Nintendo 2021-12-31 2020-10-16
Dragon Ball Xenoverse 2 1550000 Fighting Dimps Bandai Namco Entertainment 2021-12-31 2017-09-07
Pokkén Tournament DX 1540000 Fighting Bandai Namco Studios JP: The Pokémon CompanyNA/PAL: Nintendo 2022-01-02 2017-09-22
Marvel Ultimate Alliance 3: The Black Order 1500000 Action role-playing Team Ninja Nintendo 2021-12-31 2019-07-19
Nintendo Labo Toy-Con 01: Variety Kit 1420000 Construction kit Nintendo EPD Nintendo 2020-12-31 2018-04-20
Astral Chain 1280000 Action-adventure, Hack and Slash PlatinumGames Nintendo 2021-12-31 2019-08-30
WarioWare: Get It Together! 1270000 Party Nintendo EPDIntelligent Systems Nintendo 2022-03-31 2021-09-10
Naruto Shippudden: Ultimate Ninja Storm Trilogy 1260000 Fighting CyberConnect2 Bandai Namco Entertainment 2021-12-31 2017-07-27
Dr Kawashima’s Brain Training for Nintendo Switch 1200000 Puzzle Nintendo EPD, indieszero Nintendo 2021-12-31 2019-12-27
Resident Evil: Revelations Collection 1200000 Survival horror Capcom Capcom 2022-06-30 2017-11-27
Game Builder Garage 1060000 Programming Nintendo EPD Nintendo 2022-03-31 2021-06-11
Bayonetta 2 1040000 Action-adventure, Hack and Slash PlatinumGames Nintendo 2021-12-31 2018-02-16
Enter the Gungeon 1000000 Bullet hell Dodge Roll Devolver Digital 2019-03-03 2017-12-14
Fire Emblem Warriors: Three Hopes 1000000 Hack and slashRole-playing Omega Force JP: Koei TecmoNA/PAL: Nintendo 2022-08-17 2022-06-24
Fitness Boxing 1000000 Exergamerhythm Imagineer JP: ImagineerNA/PAL: Nintendo 2020-09-08 2018-12-20
Fitness Boxing 2: Rhythm and Exercise 1000000 Exergamerhythm Imagineer JP: ImagineerNA/PAL: Nintendo 2021-12-09 2020-12-04
Shin Megami Tensei V 1000000 Role-playing Atlus JP: AtlusNA: SegaPAL: Nintendo 2022-04-18 2021-11-11
Story of Seasons: Pioneers of Olive Town 1000000 Simulationrole-playing Marvelous Xseed Games 2021-11-18 2021-02-25
Thief Simulator 1000000 Stealth Noble Muffins Forever Entertainment 2021-07-16 2019-05-19

Use “anyNA(database)” to check for the presence of any missing values in the database.

anyNA(database)
## [1] FALSE

Dplyr package - mutate()

Here I utilize the mutate function to create a new variable called “pub_category”

database <- database %>%
  mutate(pub_category = case_when(
    grepl("Pokémon", publisher) ~ "The Pokémon Nintendo",
    grepl("Nintendo", publisher) ~ "Nintendo",
    TRUE ~ "Other"))
kbl(database) %>%
  kable_paper() %>%
  scroll_box(width = "100%", height = "400px")
title copies_sold genre developer publisher as_of release_date pub_category
Mario Kart 8 Deluxe 48410000 Kart racing Nintendo EPD Nintendo 2022-09-30 2017-04-28 Nintendo
Animal Crossing: New Horizons 40170000 Social simulation Nintendo EPD Nintendo 2022-09-30 2020-03-20 Nintendo
Super Smash Bros. Ultimate 29530000 Fighting Bandai Namco StudiosSora Ltd.  Nintendo 2022-09-30 2018-12-07 Nintendo
The Legend of Zelda: Breath of the Wild 27790000 Action-adventure Nintendo EPD Nintendo 2022-09-30 2017-03-03 Nintendo
Pokémon Sword and Shield 25370000 Role-playing Game Freak The Pokémon CompanyNintendo 2022-09-30 2019-11-15 The Pokémon Nintendo
Super Mario Odyssey 24400000 Platformer Nintendo EPD Nintendo 2022-09-30 2017-10-27 Nintendo
Super Mario Party 18350000 Party NDcube Nintendo 2022-09-30 2018-10-05 Nintendo
Pokémon Brilliant Diamond and Shining Pearl 14920000 Role-playing ILCA The Pokémon CompanyNintendo 2022-09-30 2021-11-19 The Pokémon Nintendo
Ring Fit Adventure 14870000 Exergamerole-playing Nintendo EPD Nintendo 2022-09-30 2019-10-18 Nintendo
Pokémon: Let’s Go, Pikachu! and Let’s Go, Eevee! 14810000 Role-playing Game Freak The Pokémon CompanyNintendo 2022-09-30 2018-11-16 The Pokémon Nintendo
Pokémon Legends: Arceus 13910000 Action role-playing Game Freak The Pokémon CompanyNintendo 2022-09-30 2022-01-28 The Pokémon Nintendo
New Super Mario Bros. U Deluxe 13310000 Platformer Nintendo EPD Nintendo 2022-03-31 2019-01-11 Nintendo
Splatoon 2 13300000 Third-person shooter Nintendo EPD Nintendo 2022-03-31 2017-07-21 Nintendo
Luigi’s Mansion 3 11430000 Action-adventure Next Level Games Nintendo 2022-03-31 2019-10-31 Nintendo
Pokémon Scarlet and Violet 10000000 Role-playing Game Freak The Pokémon CompanyNintendo 2022-11-20 2022-11-18 The Pokémon Nintendo
Super Mario 3D World + Bowser’s Fury 9430000 Platformer Nintendo EPD Nintendo 2022-03-31 2021-02-12 Nintendo
Super Mario 3D All-Stars 9070000 Platformercompilation Nintendo Nintendo 2021-12-31 2020-09-18 Nintendo
Mario Party Superstars 8070000 Party NDcube Nintendo 2022-09-30 2021-10-29 Nintendo
Splatoon 3 7900000 Third-person shooter Nintendo EPD Nintendo 2022-09-30 2022-09-09 Nintendo
Super Mario Maker 2 7890000 PlatformerLevel editor Nintendo EPD Nintendo 2021-12-31 2019-06-28 Nintendo
Monster Hunter Rise 7700000 Action role-playing Capcom Capcom 2021-12-31 2021-03-26 Other
Nintendo Switch Sports 6150000 Sports Nintendo EPD Nintendo 2022-09-30 2022-04-29 Nintendo
The Legend of Zelda: Link’s Awakening 6080000 Action-adventure Grezzo Nintendo 2021-12-31 2019-09-20 Nintendo
Kirby and the Forgotten Land 5270000 Platformer HAL Laboratory Nintendo 2022-09-30 2022-03-25 Nintendo
Mario Tennis Aces 4280000 Sports Camelot Software Planning Nintendo 2021-12-31 2018-06-22 Nintendo
Clubhouse Games: 51 Worldwide Classics 4220000 Tabletop game NDcube Nintendo 2022-03-31 2020-06-05 Nintendo
Donkey Kong Country: Tropical Freeze 4120000 Platformer Retro Studios Nintendo 2021-12-31 2018-05-04 Nintendo
Hyrule Warriors: Age of Calamity 4000000 Hack and slash Omega Force .mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}JP: Koei TecmoNA/PAL: Nintendo 2022-01-04 2020-11-20 Nintendo
Kirby Star Allies 3980000 Platformer HAL Laboratory Nintendo 2021-12-31 2018-03-16 Nintendo
The Legend of Zelda: Skyward Sword HD 3910000 Action-adventure Tantalus Media Nintendo 2022-03-31 2021-07-16 Nintendo
Fire Emblem: Three Houses 3820000 Tactical role-playing Intelligent SystemsKoei Tecmo Nintendo 2021-12-31 2019-07-26 Nintendo
1-2-Switch 3630000 Party Nintendo EPD Nintendo 2021-12-31 2017-03-03 Nintendo
Momotaro Dentetsu: Showa, Heisei, Reiwa Mo Teiban! 3500000 Board game Konami JP: Konami 2022-03-22 2020-11-19 Other
Paper Mario: The Origami King 3340000 Role-playingaction-adventure Intelligent Systems Nintendo 2021-12-31 2020-07-17 Nintendo
Minecraft 3310000 Sandboxsurvival Mojang JP: Xbox Game StudiosNA/PAL: Mojang 2022-10-22 2017-05-11 Other
Among Us 3200000 Partysocial deduction Innersloth Innersloth 2020-12-31 2020-12-15 Other
Yoshi’s Crafted World 3010000 Platformer Good-Feel Nintendo 2021-12-31 2019-03-29 Nintendo
Metroid Dread 2900000 Action-adventure MercurySteamNintendo EPD Nintendo 2022-03-31 2021-10-08 Nintendo
New Pokémon Snap 2740000 Photography Bandai Namco Studios JP: The Pokémon CompanyNA/PAL: Nintendo 2022-05-15 2021-04-30 The Pokémon Nintendo
Arms 2660000 Fighting Nintendo EPD Nintendo 2021-12-31 2017-06-16 Nintendo
Xenoblade Chronicles 2 2440000 Action role-playing Monolith Soft Nintendo 2021-12-31 2017-12-01 Nintendo
Mario Golf: Super Rush 2350000 Sports Camelot Software Planning Nintendo 2022-03-31 2021-06-25 Nintendo
Pikmin 3 Deluxe 2230000 Real-time strategypuzzle Nintendo EPDEighting Nintendo 2021-12-31 2020-10-30 Nintendo
Mario Strikers: Battle League 2170000 Sports Next Level Games Nintendo 2022-09-30 2022-06-10 Nintendo
Octopath Traveler 2160000 Role-playing Square EnixAcquire JP: Square EnixNA/PAL: Nintendo 2022-01-02 2018-07-13 Nintendo
Captain Toad: Treasure Tracker 2130000 Action puzzle Nintendo EPD Nintendo 2021-12-31 2018-07-13 Nintendo
Dragon Ball FighterZ 2010000 Fighting Arc System Works Bandai Namco Entertainment 2021-12-31 2018-09-27 Other
Mario + Rabbids Kingdom Battle 2000000 Tactical role-playing Ubisoft ParisUbisoft Milan NA/PAL: UbisoftJP/KOR: Nintendo[18] 2018-09-02 2017-08-29 Nintendo
Pokémon Mystery Dungeon: Rescue Team DX 1890000 Roguelike Spike Chunsoft Nintendo 2021-12-31 2020-03-06 Nintendo
Taiko no Tatsujin: Drum ‘n’ Fun! 1890000 Rhythm Bandai Namco Studios Bandai Namco Entertainment 2021-12-31 2018-07-19 Other
Xenoblade Chronicles 3 1720000 Action role-playing Monolith Soft Nintendo 2022-09-30 2022-07-29 Nintendo
Miitopia 1680000 Role-playing Grezzo Nintendo 2022-03-31 2021-05-21 Nintendo
Xenoblade Chronicles: Definitive Edition 1680000 Action role-playing Monolith Soft Nintendo 2021-12-31 2020-05-29 Nintendo
Big Brain Academy: Brain vs. Brain 1590000 Puzzle Nintendo EPD Nintendo 2022-03-31 2021-12-03 Nintendo
Mario Kart Live: Home Circuit 1580000 Kart racingaugmented reality Velan Studios Nintendo 2021-12-31 2020-10-16 Nintendo
Dragon Ball Xenoverse 2 1550000 Fighting Dimps Bandai Namco Entertainment 2021-12-31 2017-09-07 Other
Pokkén Tournament DX 1540000 Fighting Bandai Namco Studios JP: The Pokémon CompanyNA/PAL: Nintendo 2022-01-02 2017-09-22 The Pokémon Nintendo
Marvel Ultimate Alliance 3: The Black Order 1500000 Action role-playing Team Ninja Nintendo 2021-12-31 2019-07-19 Nintendo
Nintendo Labo Toy-Con 01: Variety Kit 1420000 Construction kit Nintendo EPD Nintendo 2020-12-31 2018-04-20 Nintendo
Astral Chain 1280000 Action-adventure, Hack and Slash PlatinumGames Nintendo 2021-12-31 2019-08-30 Nintendo
WarioWare: Get It Together! 1270000 Party Nintendo EPDIntelligent Systems Nintendo 2022-03-31 2021-09-10 Nintendo
Naruto Shippudden: Ultimate Ninja Storm Trilogy 1260000 Fighting CyberConnect2 Bandai Namco Entertainment 2021-12-31 2017-07-27 Other
Dr Kawashima’s Brain Training for Nintendo Switch 1200000 Puzzle Nintendo EPD, indieszero Nintendo 2021-12-31 2019-12-27 Nintendo
Resident Evil: Revelations Collection 1200000 Survival horror Capcom Capcom 2022-06-30 2017-11-27 Other
Game Builder Garage 1060000 Programming Nintendo EPD Nintendo 2022-03-31 2021-06-11 Nintendo
Bayonetta 2 1040000 Action-adventure, Hack and Slash PlatinumGames Nintendo 2021-12-31 2018-02-16 Nintendo
Enter the Gungeon 1000000 Bullet hell Dodge Roll Devolver Digital 2019-03-03 2017-12-14 Other
Fire Emblem Warriors: Three Hopes 1000000 Hack and slashRole-playing Omega Force JP: Koei TecmoNA/PAL: Nintendo 2022-08-17 2022-06-24 Nintendo
Fitness Boxing 1000000 Exergamerhythm Imagineer JP: ImagineerNA/PAL: Nintendo 2020-09-08 2018-12-20 Nintendo
Fitness Boxing 2: Rhythm and Exercise 1000000 Exergamerhythm Imagineer JP: ImagineerNA/PAL: Nintendo 2021-12-09 2020-12-04 Nintendo
Shin Megami Tensei V 1000000 Role-playing Atlus JP: AtlusNA: SegaPAL: Nintendo 2022-04-18 2021-11-11 Nintendo
Story of Seasons: Pioneers of Olive Town 1000000 Simulationrole-playing Marvelous Xseed Games 2021-11-18 2021-02-25 Other
Thief Simulator 1000000 Stealth Noble Muffins Forever Entertainment 2021-07-16 2019-05-19 Other

Dplyr package - summarise()

Here I utilize the summarise function to aggregate data by “pub_category”, calculating the total sales and counting the number of records in each category.

datasum<- database %>%
group_by(pub_category) %>%
summarise(total_sales = sum(copies_sold),count = n())
datasum
## # A tibble: 3 × 3
##   pub_category         total_sales count
##   <chr>                      <dbl> <int>
## 1 Nintendo               383680000    54
## 2 Other                   28620000    12
## 3 The Pokémon Nintendo    83290000     7

ggplot2 package - ggplot()

Here, I employ the ggplot function to generate a bar plot, representing the total sales by publisher categories.

ggplot(datasum, aes(x = pub_category, y = total_sales, fill = pub_category)) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(title = "Copy Sales by Publisher (in Millions)", x = "Publisher", y = "Total Sales") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))+
  scale_y_continuous(labels = function(x) sprintf("%.2fM", x/1000000))