class: center, title-slide # STAT 302, Lecture Slides 4 ## Regular Expressions and Strings ### Peter Gao (adapted from slides by Bryan Martin) --- # Outline 1. Strings 2. Factors 3. Dates and Times 4. Regular Expressions .middler[**Goal:** Learn how to efficiently work with strings, factors, and dates!] --- ```r library(tidyverse) ``` ``` ## ── Attaching packages ─────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.1 ── ``` ``` ## ✓ ggplot2 3.3.3 ✓ purrr 0.3.4 ## ✓ tibble 3.1.2 ✓ dplyr 1.0.6 ## ✓ tidyr 1.1.3 ✓ stringr 1.4.0 ## ✓ readr 1.4.0 ✓ forcats 0.5.1 ``` ``` ## ── Conflicts ────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ── ## x dplyr::filter() masks stats::filter() ## x dplyr::group_rows() masks kableExtra::group_rows() ## x dplyr::lag() masks stats::lag() ``` --- # Today's data set ```r board_games <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-03-12/board_games.csv") ``` ``` ## ## ── Column specification ─────────────────────────────────────────────────────────────────────────────────── ## cols( ## .default = col_character(), ## game_id = col_double(), ## max_players = col_double(), ## max_playtime = col_double(), ## min_age = col_double(), ## min_players = col_double(), ## min_playtime = col_double(), ## playing_time = col_double(), ## year_published = col_double(), ## average_rating = col_double(), ## users_rated = col_double() ## ) ## ℹ Use `spec()` for the full column specifications. ``` ```r board_games <- board_games %>% filter(year_published >= 2000) ``` --- # Today's data set ```r head(board_games) ``` ``` ## # A tibble: 6 x 22 ## game_id description image max_players max_playtime min_age min_players min_playtime name playing_time ## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> ## 1 387 Described by… //cf.… 7 45 10 3 45 Corr… 45 ## 2 475 Northwest In… //cf.… 5 100 12 3 75 Taj … 100 ## 3 478 In Citadels,… //cf.… 8 60 10 2 20 Cita… 60 ## 4 481 This game us… //cf.… 4 60 12 2 60 Caro… 60 ## 5 490 Warangel is … //cf.… 6 60 12 2 60 Wara… 60 ## 6 491 Players stru… //cf.… 5 60 12 3 50 Web … 60 ## # … with 12 more variables: thumbnail <chr>, year_published <dbl>, artist <chr>, category <chr>, ## # compilation <chr>, designer <chr>, expansion <chr>, family <chr>, mechanic <chr>, publisher <chr>, ## # average_rating <dbl>, users_rated <dbl> ``` --- # Today's data set ```r ggplot(board_games, aes(x = users_rated, y = average_rating)) + geom_point() + labs(x = "Number of ratings", y = "Average rating") + theme_bw() ``` <!-- --> --- layout: false class: inverse .sectionhead[Part 1: Strings] --- # Strings ## What are strings? A **character** is a symbol from a written language, such as a letter, a numeric, a symbol, or otherwise. A **string** is a collection of characters grouped together (such as a word). Even when we do quantitative work, lots of important and interesting data often comes in the form of strings, and knowing how to work with them is essential for data scientists and statisticians. --- # Today's data set ```r board_games$name ``` ``` ## [1] "Corruption" ## [2] "Taj Mahal" ## [3] "Citadels" ## [4] "Carolus Magnus" ## [5] "Warangel" ## [6] "Web of Power" ## [7] "Aladdin's Dragons" ## [8] "Time Pirates" ## [9] "Vampire" ## [10] "The Reef" ## [11] "Eschnapur" ## [12] "Merchants of Amsterdam" ## [13] "Labyrinth: The Card Game" ## [14] "Democrazy" ## [15] "Battle Cry" ## [16] "La Città" ## [17] "The Princes of Florence" ## [18] "7 Safari" ## [19] "Laguna" ## [20] "Der weiße Lotus" ## [21] "Silberzwerg" ## [22] "Port Royal" ## [23] "Wongar" ## [24] "Das Kollier" ## [25] "Kardinal" ## [26] "Die Weinhändler" ## [27] "MLB Showdown" ## [28] "Royal Tank Corps" ## [29] "River Dragons" ## [30] "Hera and Zeus" ## [31] "Deadlands: Doomtown Range Wars" ## [32] "Shipwrecked" ## [33] "Pirate's Plunder" ## [34] "Mystick Domination" ## [35] "Fairy Meat" ## [36] "Castle" ## [37] "Riffifi" ## [38] "Monopoly: The Card Game" ## [39] "Wizard Kings" ## [40] "The Big Idea" ## [41] "Gother Than Thou" ## [42] "Galaxy: The Dark Ages" ## [43] "San Francisco" ## [44] "Lunatix Loop" ## [45] "Battle Line" ## [46] "The Great Brain Robbery" ## [47] "Keytown" ## [48] "Star Trek Red Alert" ## [49] "Kings and Castles" ## [50] "Letter Head" ## [51] "The Hills Rise Wild!" ## [52] "Buffy the Vampire Slayer: The Game" ## [53] "Chrononauts" ## [54] "Carcassonne" ## [55] "Lord of the Rings" ## [56] "Cartagena" ## [57] "Attila" ## [58] "Battle of the Bands" ## [59] "New England Railways" ## [60] "Corsairs" ## [61] "Circus Minimus" ## [62] "Mausoleum" ## [63] "Golf Masters" ## [64] "Doge" ## [65] "Java" ## [66] "Mage Knight" ## [67] "Morisi" ## [68] "Bongo!" ## [69] "Empires of the Ancient World" ## [70] "M" ## [71] "Tennis Masters" ## [72] "Troia" ## [73] "Wyatt Earp" ## [74] "Ivanhoe" ## [75] "Way Out West" ## [76] "Meuterer" ## [77] "Hamsterrolle" ## [78] "Dream Factory" ## [79] "Pacific Victory" ## [80] "Piraten-Pitt" ## [81] "Lift Off" ## [82] "Gerüchteküche" ## [83] "Star Wars: The Queen's Gambit" ## [84] "Turbo Taxi" ## [85] "Four Dragons" ## [86] "Azteca" ## [87] "Orcz" ## [88] "The Powerpuff Girls: Saving the World Before Bedtime" ## [89] "Al Cabohne" ## [90] "Babel" ## [91] "Zapp Zerapp" ## [92] "San Marco" ## [93] "Dragon's Gold" ## [94] "Pitstop" ## [95] "Titus" ## [96] "Kathai" ## [97] "Big Shot" ## [98] "Capitol" ## [99] "Save Doctor Lucky" ## [100] "Evo" ## [101] "Witch Trial" ## [102] "Luxor" ## [103] "Big Deal" ## [104] "Monkey Memory" ## [105] "Right Turn, Left Turn" ## [106] "Meander" ## [107] "Isis & Osiris" ## [108] "Limits" ## [109] "Medina" ## [110] "Axis & Allies: Pacific" ## [111] "Knatsch" ## [112] "Der Schattendieb" ## [113] "Mystery Rummy: Jekyll & Hyde" ## [114] "Im Zeichen des Kreuzes" ## [115] "Ulysses" ## [116] "Confusion" ## [117] "Die Magier von Pangea" ## [118] "Nur Peanuts!" ## [119] "1826" ## [120] "Warhamster Rally" ## [121] "Africa" ## [122] "Auf falscher Fährte" ## [123] "Magic Hill" ## [124] "Chip-Chip Hurra" ## [125] "Café International: Das Kartenspiel" ## [126] "Savannah Café" ## [127] "Boom-O" ## [128] "Entdecker: Exploring New Horizons" ## [129] "Gnadenlos!" ## [130] "Eden" ## [131] "Volldampf" ## [132] "Genoa" ## [133] "Crazy Race" ## [134] "Das Amulett" ## [135] "Bali" ## [136] "Zaubercocktail" ## [137] "Hexen Rennen" ## [138] "Pillage & Plunder" ## [139] "Don" ## [140] "Danger" ## [141] "Odysseus" ## [142] "Ebbe & Flut" ## [143] "Winner's Circle" ## [144] "Strand-Cup" ## [145] "Trendy" ## [146] "Meridian" ## [147] "Lord of the Rings: The Search" ## [148] "Der grosse Gallier" ## [149] "Canasta Caliente" ## [150] "Girl Genius: The Works" ## [151] "Venezia" ## [152] "Chief Herman's Holiday Fun Pack" ## [153] "Ghost Chase" ## [154] "Flowerpower" ## [155] "Tenjo" ## [156] "Sicily: Triumph and Folly" ## [157] "Cortez" ## [158] "Pokémon Jr. Adventure Game: Pokémon Emergency!" ## [159] "Bounty" ## [160] "Clue: Dungeons & Dragons" ## [161] "Unexploded Cow" ## [162] "Toscana" ## [163] "Im Märchenwald" ## [164] "Cosmic Coasters" ## [165] "Pampas Railroads" ## [166] "Warlord: Saga of the Storm" ## [167] "Rüsselbande" ## [168] "Devil Bunny Hates the Earth" ## [169] "Grant Takes Command" ## [170] "Wilderness War" ## [171] "Risk 2210 A.D." ## [172] "Pig Pile" ## [173] "Star Fleet Battle Force" ## [174] "Mad Scientist" ## [175] "Munchkin" ## [176] "Frag" ## [177] "Online: Internet Card Game" ## [178] "Imperium: 3rd Millennium" ## [179] "Vegas" ## [180] "Bladder" ## [181] "Flagship: Prometheus Unchained" ## [182] "Proteus" ## [183] "eBay Electronic Talking Auction Game" ## [184] "Chez Dork" ## [185] "Zero!" ## [186] "Gobblet" ## [187] "Lost Patrol" ## [188] "Fight!" ## [189] "U.S. Patent No. 1" ## [190] "Kasserine" ## [191] "Atlantis: Pathways of the Deep" ## [192] "X-Bugs" ## [193] "Starship Catan" ## [194] "HellRail: Third Perdition" ## [195] "Titicaca" ## [196] "DVONN" ## [197] "Muscat" ## [198] "Ur: 1830 BC" ## [199] "Ghoulash" ## [200] "Kanaloa" ## [201] "Halloween Party" ## [202] "MotorChamp" ## [203] "Blokus" ## [204] "The Hobbit: The Defeat of Smaug" ## [205] "Battle Cattle: The Card Game" ## [206] "Zombies!!!" ## [207] "Grave Robbers From Outer Space" ## [208] "Industrial Waste" ## [209] "Saloon" ## [210] "Liberté" ## [211] "Nexus" ## [212] "Kupferkessel Co." ## [213] "Vabanque" ## [214] "Draco & Co" ## [215] "Urland" ## [216] "Beest" ## [217] "Cosmic Cows" ## [218] "Gargon" ## [219] "Pompeji" ## [220] "Vom Kap bis Kairo" ## [221] "Who Stole Ed's Pants?" ## [222] "Pick Picknic" ## [223] "Atlantic Star" ## [224] "Classic Warlord" ## [225] "Winhard" ## [226] "Villa Paletti" ## [227] "Jurassic Park III Island Survival Game" ## [228] "Gods" ## [229] "Solitaire for Two" ## [230] "The Lord of the Rings Trading Card Game" ## [231] "Kardinal & König: Das Kartenspiel" ## [232] "The HellGame" ## [233] "Rome At War I: Hannibal at Bay" ## [234] "Clash of Giants" ## [235] "Power Grid" ## [236] "Hive" ## [237] "Der Herr der Ringe: Die Gefährten – Das Kartenspiel" ## [238] "Coppertwaddle" ## [239] "Frachtexpress" ## [240] "Alibi" ## [241] "Der Herr der Ringe: Die Gefährten" ## [242] "War! Age of Imperialism" ## [243] "Hossa!" ## [244] "The Gnumies" ## [245] "Thirty Years War: Europe in Agony, 1618-1648" ## [246] "The American Civil War" ## [247] "Ein Arsch kommt selten allein" ## [248] "Maginor" ## [249] "Knights of the Dinner Table: HACK!" ## [250] "Safari" ## [251] "My Word!" ## [252] "Spinball" ## [253] "Delta V" ## [254] "Trivial Pursuit: Genus 5" ## [255] "TransAmerica" ## [256] "BrewMaster: The Craft Beer Game" ## [257] "Jungle Jam" ## [258] "Piecepack" ## [259] "Patton in Flames" ## [260] "Mage Knight Dungeons" ## [261] "The Yeti Slalom" ## [262] "Nanofictionary" ## [263] "In Pursuit" ## [264] "Twilight Imperium: Armada" ## [265] "John Prados' Third Reich" ## [266] "Monopoly: The .com Edition" ## [267] "Dice Run" ## [268] "Diceland" ## [269] "A Dog's Life" ## [270] "Mexica" ## [271] "Camden" ## [272] "Ka-Ching!" ## [273] "Fantasy Business" ## [274] "Bionicle Adventure Game: Quest For Makuta" ## [275] "The Simpsons Trivia Game" ## [276] "Pirate's Cove" ## [277] "Soldier Kings" ## [278] "Reds! The Russian Civil War 1918-1921" ## [279] "Crash Tackle Rugby Board Game" ## [280] "Monopoly: Looney Tunes" ## [281] "Warp 6" ## [282] "Monopoly: Stock Exchange" ## [283] "Hamlet!" ## [284] "Puerto Rico" ## [285] "Knockabout" ## [286] "Age of Empires II" ## [287] "Clippers" ## [288] "Captain Park's Imaginary Polar Expedition" ## [289] "Cairo" ## [290] "Goldland" ## [291] "The Bucket King" ## [292] "Nautilus" ## [293] "Lumberjack" ## [294] "Zahltag" ## [295] "Car Wars (fifth edition)" ## [296] "Lord of the Rings: The Confrontation" ## [297] "Dragonland" ## [298] "Hekla" ## [299] "Pueblo" ## [300] "Tyros" ## [301] "Die Sieben Weisen" ## [302] "Dschunke" ## [303] "WildLife" ## [304] "Clash of the Gladiators" ## [305] "Wooly Bully" ## [306] "The Powerpuff Girls: Villains at Large Game" ## [307] "Ukraine '43" ## [308] "Pizarro & Co." ## [309] "Clue: The Card Game" ## [310] "Cat Attack" ## [311] "Imperator" ## [312] "Magi-Nation Duel" ## [313] "Star Wars: Epic Duels" ## [314] "Star Wars: Jedi Unleashed" ## [315] "Wallenstein (first edition)" ## [316] "Prussia's Glory" ## [317] "Royal Hearts" ## [318] "Heave Ho!" ## [319] "The Game of Life: A Jedi's Path" ## [320] "Die Pyramiden des Jaguar" ## [321] "Diceland: Deep White Sea" ## [322] "Hard Vacuum" ## [323] "Burn Rate" ## [324] "Santa Fe Rails" ## [325] "Gouda! Gouda!" ## [326] "World War II: Barbarossa to Berlin" ## [327] "Wie Hund und Katz!" ## [328] "Affenraffen" ## [329] "San Gimignano" ## [330] "Stratego: Star Wars" ## [331] "Ivanhoë" ## [332] "Monopoly: The Simpsons" ## [333] "Tin Soldiers" ## [334] "This Accursed Civil War" ## [335] "The Napoleonic Wars" ## [336] "Drive on Paris" ## [337] "Brandywine" ## [338] "Fallschirmjaeger" ## [339] "StreetSoccer" ## [340] "Fantasy" ## [341] "Golden Deuce" ## [342] "HeroClix" ## [343] "Emerald" ## [344] "Harry Potter Trading Card Game" ## [345] "By Golly!" ## [346] "Napoleon in Europe" ## [347] "Vampire Hunter" ## [348] "Spider-Man" ## [349] "Theophrastus" ## [350] "The Lord of the Rings: The Fellowship of the Ring" ## [351] "Roller Coaster Tycoon" ## [352] "BattleBots: Kickbot Arena" ## [353] "Squint" ## [354] "Mamba" ## [355] "eBay: The Card Game" ## [356] "Survivor" ## [357] "Chaostle" ## [358] "Too Many Cooks" ## [359] "Sid Meier's Civilization: The Boardgame" ## [360] "The Settlers of Canaan" ## [361] "Cube Farm" ## [362] "Tribbles Customizable Card Game" ## [363] "Hammer of the Scots" ## [364] "Killer Bunnies and the Quest for the Magic Carrot" ## [365] "Gregory Horror Show" ## [366] "Qwitch" ## [367] "Sumo!" ## [368] "Palazzo Paletti" ## [369] "Himalaya" ## [370] "When Darkness Comes" ## [371] "Breakthrough" ## [372] "Locomotive Werks" ## [373] "Firestorm" ## [374] "RIFTS Collectible Card Game" ## [375] "Mechwarrior: Dark Age" ## [376] "7 Ages" ## [377] "Ali Baba" ## [378] "Harry Potter: Diagon Alley Board Game" ## [379] "Street Illegal" ## [380] "Smart Mouth" ## [381] "Mare Nostrum" ## [382] "Cannibal Pygmies in the Jungle of Doom" ## [383] "BANG!" ## [384] "Catan: Portable Edition" ## [385] "Strong Stuff!" ## [386] "Fact or Crap" ## [387] "Advanced Tobruk" ## [388] "Harry Potter and the Sorcerer's Stone Quidditch Card Game" ## [389] "Frag Deadlands" ## [390] "Man Bites Dog" ## [391] "War of the States: Gettysburg, 1863" ## [392] "Star Wars: Trading Card Game" ## [393] "Swap!" ## [394] "Rats!" ## [395] "Management Material (General Office Edition)" ## [396] "Who Wants to Be a Millionaire" ## [397] "Can't Stop the Turtles" ## [398] "wordXchange" ## [399] "Star Munchkin" ## [400] "Nodwick: The Card Game" ## [401] "Age of Steam" ## [402] "Keythedral" ## [403] "The Wheel of Time Collectible Card Game" ## [404] "Moderne Zeiten" ## [405] "Hang in There!" ## [406] "X-Men Trading Card Game" ## [407] "Arne" ## [408] "Bakari" ## [409] "Lifeboat" ## [410] "Diskwars: Legend of the Five Rings" ## [411] "ShowBiz Shuffle" ## [412] "Monza" ## [413] "O Zoo le Mio" ## [414] "Goal" ## [415] "Quest for the Dragonlords" ## [416] "Trias" ## [417] "Globopolis" ## [418] "Mäuse-Rallye" ## [419] "Crafty Badger" ## [420] "Freeloader" ## [421] "A Game of Thrones Collectible Card Game" ## [422] "Cannes: Stars, Scripts and Screens" ## [423] "VOC! Founding the Dutch East Indies Company" ## [424] "Risk: The Lord of the Rings" ## [425] "Virus & Co" ## [426] "War & Sheep" ## [427] "Tony & Tino" ## [428] "Drake & Drake" ## [429] "Kanaloa" ## [430] "Screaming Eagles in Holland" ## [431] "Fightball" ## [432] "Monkeys on the Moon" ## [433] "Nero" ## [434] "Fische Fluppen Frikadellen" ## [435] "Froop!" ## [436] "Krone & Schwert" ## [437] "Im Schatten des Sonnenkönigs" ## [438] "Rome: Imperium, Circus Maximus, Hannibal vs Rome" ## [439] "Carcassonne: Hunters and Gatherers" ## [440] "The Settlers of the Stone Age" ## [441] "Bean Trader" ## [442] "Odin's Ravens" ## [443] "Canal Grande" ## [444] "Bayon" ## [445] "Ad Acta" ## [446] "Hoopla" ## [447] "Waterloo: Napoleon's Last Battle" ## [448] "Gaudí" ## [449] "Oraklos" ## [450] "Delphi" ## [451] "Fist of Dragonstones" ## [452] "Unexpected Treasures" ## [453] "Station Manager" ## [454] "Scarab Lords" ## [455] "Cave Troll" ## [456] "Trivial Pursuit: 20th Anniversary Edition" ## [457] "König der Maulwürfel" ## [458] "Maskenball der Käfer" ## [459] "Hellas" ## [460] "Thud" ## [461] "Attribute" ## [462] "Mogul" ## [463] "Racko Plus" ## [464] "Blooming Gardens" ## [465] "Chez Greek" ## [466] "Sucking Vacuum" ## [467] "Lord of the Rings: The Duel" ## [468] "1854" ## [469] "Arimaa" ## [470] "The Prestel New York Architecture Game" ## [471] "Clans" ## [472] "Fire and Ice" ## [473] "Moods" ## [474] "Friends Trivia Game" ## [475] "The Lord of the Rings: The Fellowship of the Ring" ## [476] "Warmachine" ## [477] "Battlecards: World Conflict – Western European Campaign – Starter Set" ## [478] "King's Gate" ## [479] "Der Herr der Ringe: Die Zwei Türme – das Kartenspiel" ## [480] "Xactika" ## [481] "Cookie Fu" ## [482] "Scene It? Movie" ## [483] "Dragon Strike" ## [484] "Great War at Sea: 1898, The Spanish American War" ## [485] "Great War at Sea: U.S. Navy Plan Red" ## [486] "1313 Dead End Drive" ## [487] "Sunda to Sahul" ## [488] "Rome at War II: Fading Legions" ## [489] "Cityscape" ## [490] "Der Herr der Ringe: Die Zwei Türme" ## [491] "Warmaster" ## [492] "Apples to Apples Kids" ## [493] "Hands Up" ## [494] "The Worst-Case Scenario Survival Game" ## [495] "Caesar in Alexandria" ## [496] "Fubi" ## [497] "Doubles Wild" ## [498] "The Simpsons: LOSER Takes All!" ## [499] "GolfProfi" ## [500] "Drakborgen Legenden" ## [501] "Marrakesh" ## [502] "Old Town" ## [503] "Star Wars: Jedi Knights CCG" ## [504] "Hilarium" ## [505] "Curses!" ## [506] "LEGO Soccer" ## [507] "Split (Revised Edition)" ## [508] "Von Manstein's Backhand Blow" ## [509] "Chomp!" ## [510] "Wheedle" ## [511] "Amun-Re" ## [512] "New England" ## [513] "Magna Grecia" ## [514] "Mad Gab Card Game" ## [515] "Best of TriBond" ## [516] "Granada: The Fall of Moslem Spain" ## [517] "Dread Pirate" ## [518] "Clue: The Haunted Mansion" ## [519] "Snap: The Interlocking Dragon-Making Game" ## [520] "Monopoly: Millennium" ## [521] "Crazy Circus" ## [522] "Vive l'Empereur" ## [523] "Time is Money" ## [524] "Talkin' Tango" ## [525] "Yu-Gi-Oh! DungeonDice Monsters" ## [526] "Light Speed" ## [527] "Vampire" ## [528] "PeaceBowl" ## [529] "Dungeoneer: Tomb of the Lich Lord" ## [530] "UNO: Harry Potter" ## [531] "Second World War at Sea: Bomb Alley" ## [532] "Bombay Bazar" ## [533] "18EU" ## [534] "Highly Suspect" ## [535] "Reiner Knizia's Amazing Flea Circus" ## [536] "Second World War at Sea: Eastern Fleet" ## [537] "Capt'n Clever" ## [538] "Cuckoo Zoo" ## [539] "Squad Seven" ## [540] "Balloon Cup" ## [541] "Domaine" ## [542] "Harry Potter and the Sorcerer's Stone Trivia Game" ## [543] "Bakerstreet" ## [544] "Monopoly: Star Trek Limited Edition" ## [545] "Mammoth Hunters" ## [546] "Oh, Really!" ## [547] "Edel, Stein & Reich" ## [548] "Coloretto" ## [549] "Polterdice" ## [550] "Battle of the Sexes Card Game" ## [551] "Maelstrom" ## [552] "Richelieu" ## [553] "Brute Force: The War in the West, 1940-1945" ## [554] "The Kids of Catan" ## [555] "Paris Paris" ## [556] "Steam Tunnel" ## [557] "10 Days in Europe" ## [558] "Die Dracheninsel" ## [559] "Mermaid Rain" ## [560] "Mystery Rummy: Al Capone and the Chicago Underworld" ## [561] "Phantom Rallye" ## [562] "Duel of Ages Set 1: Worldspanner" ## [563] "Queen's Necklace" ## [564] "Pack of Flies" ## [565] "Nobody but Us Chickens" ## [566] "Discovery" ## [567] "Drive" ## [568] "Avalon" ## [569] "The Sun of Austerlitz" ## [570] "Dante's Inferno" ## [571] "The Rise of the Roman Republic" ## [572] "Europe Engulfed" ## [573] "Mag·Blast (Second Edition)" ## [574] "The Perilous Parlor Game" ## [575] "Alhambra" ## [576] "Chez Grunt" ## [577] "Arnhem: Defiant Stand" ## [578] "King's Breakfast" ## [579] "Eketorp" ## [580] "Dying Lights" ## [581] "Gulo Gulo" ## [582] "Lord of the Rings" ## [583] "Monty's Gamble: Market Garden" ## [584] "Dungeons & Dragons: The Fantasy Adventure Board Game" ## [585] "King Arthur" ## [586] "Napoleon at the Berezina" ## [587] "WarCry" ## [588] "Sequence for Kids" ## [589] "Blokus 3D" ## [590] "Cranium Cadoo" ## [591] "The Testimony of Jacob Hollow" ## [592] "A Game of Thrones (first edition)" ## [593] "Phoenix" ## [594] "Quidditch: The Game" ## [595] "Iron Tide: Panzers in the Ardennes" ## [596] "Tom Tube" ## [597] "Magdar" ## [598] "Panzer Grenadier: Airborne" ## [599] "Dwarven Dig!" ## [600] "Maya Madness" ## [601] "Formula Dé Mini" ## [602] "Fear God and Dread Nought" ## [603] "Lock 'n Load: Forgotten Heroes – Vietnam" ## [604] "Crimson Skies" ## [605] "Pussy Cat" ## [606] "Lawless" ## [607] "Diceland: Space" ## [608] "Glory II: Across the Rappahannock" ## [609] "VisualEyes" ## [610] "Cronberg" ## [611] "Korea: The Forgotten War" ## [612] "Let's Do Lunch!" ## [613] "Kung Fu Samurai on Giant Robot Island" ## [614] "Grave Robbers II: Skippy's Revenge" ## [615] "Munchkin Fu" ## [616] "Lord of the Rings Trivia Game" ## [617] "Spinergy" ## [618] "Battlelines: The Stalingrad Campaign" ## [619] "Downtown: Air War Over Hanoi, 1965-1972" ## [620] "Scream Machine" ## [621] "Spite & Malice" ## [622] "Strange Synergy" ## [623] "Lunar Rails" ## [624] "Shadowrun Duels" ## [625] "Battlecards: World Conflict – Pacific Theatre – Starter Set" ## [626] "Battlecards: World Conflict – The Russian Front – Starter Set" ## [627] "Batman: Gotham City Mystery" ## [628] "Age of Mythology: The Boardgame" ## [629] "Eureka!" ## [630] "Hit the Deck" ## [631] "Anathema" ## [632] "Liberty: The American Revolution 1775-83" ## [633] "Battleship: Star Wars Advanced Mission" ## [634] "Quicksand" ## [635] "Dungeons & Dragons Chainmail" ## [636] "Busen Memo" ## [637] "Diceland: Ogre" ## [638] "Attack!" ## [639] "Attack Vector: Tactical" ## [640] "The Settlers of Zarahemla" ## [641] "The Ark of the Covenant" ## [642] "Big Brother: The Game" ## [643] "Battleball" ## [644] "Pacru" ## [645] "Gold und Rum" ## [646] "Zendo" ## [647] "Electronic Battleship Advanced Mission" ## [648] "Teams of Enemies" ## [649] "Transformers Armada: Battle for Cybertron" ## [650] "Red Badge of Courage" ## [651] "Hear Me Out" ## [652] "Sweden Fights On" ## [653] "Lara Croft: Tomb Raider – The Angel of Darkness" ## [654] "Reiner Knizia's Decathlon" ## [655] "Jeopardy! Simpsons Edition" ## [656] "Mission Command Land" ## [657] "Match of the Penguins" ## [658] "Mission Command Sea" ## [659] "Mission Command Air" ## [660] "The Mother Lode of Sticky Gulch" ## [661] "Big Top" ## [662] "Smarty Party!" ## [663] "Senjutsu: Dynamic Samurai Combat" ## [664] "Schloss Schlotterstein" ## [665] "Portable Adventures: 8th Grade" ## [666] "Portable Adventures: Lair of the Rat-King" ## [667] "Battles of the Ancient World Volume III" ## [668] "Guilford" ## [669] "Panzer Grenadier: Afrika Korps" ## [670] "Scottish Corridor: Lion Rampant" ## [671] "The Killing Ground" ## [672] "Catz, Ratz and Batz" ## [673] "Warhammer 40,000 Collectible Card Game" ## [674] "Heroes of the Soviet Union: The Defense of Mother Russia 1942-43" ## [675] "Panzer Grenadier: Battle of the Bulge" ## [676] "Panzer Grenadier: Semper Fi! Guadalcanal" ## [677] "Monopoly: Nostalgia Wooden Box" ## [678] "Myths and Legends" ## [679] "TimeLine" ## [680] "Pitch Six" ## [681] "Ophidian 2350" ## [682] "18VA" ## [683] "Medieval" ## [684] "Vanished Planet" ## [685] "Zenix" ## [686] "Management Material: Information Technology Edition" ## [687] "Against All Odds" ## [688] "Goth: The Game of Horror Trivia" ## [689] "Cranium Hullabaloo" ## [690] "One False Step for Mankind" ## [691] "Neopets: Adventures in Neopia" ## [692] "Trivial Pursuit: The Lord of the Rings Movie Trilogy Collector's Edition" ## [693] "Battleship Card Game" ## [694] "Chekov" ## [695] "The Lord of the Rings: The Two Towers Board Game" ## [696] "WarCraft: The Board Game" ## [697] "Sword of Rome" ## [698] "Schatz der Drachen" ## [699] "A Frozen Hell" ## [700] "Zombie Plague" ## [701] "Subulata" ## [702] "Fish Eat Fish" ## [703] "Galactic Starfire" ## [704] "Go Bananas!" ## [705] "Whad'Ya Know?" ## [706] "Babylon" ## [707] "Winds Of Plunder" ## [708] "Snowball Fight" ## [709] "Thingamajig" ## [710] "Urban Myth" ## [711] "The Suicide Bomber Card Game" ## [712] "The Simpsons Board Game" ## [713] "A World at War" ## [714] "History's Mysteries Card Game" ## [715] "Hisss" ## [716] "Cluedo Passport to Murder" ## [717] "Carcassonne: The Castle" ## [718] "The Penguin Ultimatum" ## [719] "Arena Maximus" ## [720] "The Prince: The Struggle of House Borgia" ## [721] "Confrontation" ## [722] "The Italian Front: 1915-1918" ## [723] "Dracula" ## [724] "Fearsome Floors" ## [725] "King Me!" ## [726] "Creepy Freaks" ## [727] "Buffy the Vampire Slayer: The Board Game" ## [728] "Break the Safe" ## [729] "Secrets of the Tombs" ## [730] "Risorgimento 1859" ## [731] "3 Stones" ## [732] "Counting Zzzzs" ## [733] "YINSH" ## [734] "Ardennes '44" ## [735] "Simpsons Trading Card Game" ## [736] "Soldier Emperor" ## [737] "Birds, Bugs and Beans" ## [738] "10 Days in Africa" ## [739] "10 Days in the USA" ## [740] "Balancing Aliens" ## [741] "Dungeons & Dragons Miniatures" ## [742] "1844: Switzerland" ## [743] "Tortuga" ## [744] "The 80's Game" ## [745] "Flags of the World" ## [746] "Mutiny!" ## [747] "Triumph & Glory: Battles of the Napoleonic Wars 1796-1809" ## [748] "Fantasy Pub" ## [749] "Spooks" ## [750] "Battle Cry of Freedom" ## [751] "Feurio!" ## [752] "Eagles of the Empire: Napoleon in the Desert" ## [753] "Trivial Pursuit: DVD Pop Culture Game" ## [754] "Monopoly: The Lord of the Rings Trilogy Edition" ## [755] "Princes of the Renaissance" ## [756] "Attika" ## [757] "Ideology: The War of Ideas" ## [758] "Ghettopoly" ## [759] "Clue FX" ## [760] "MLB SportsClix" ## [761] "X-Machina" ## [762] "Bulls-Eye Ball" ## [763] "Prophecy" ## [764] "Logistico" ## [765] ".hack//ENEMY" ## [766] "Risk: The Lord of the Rings Trilogy Edition" ## [767] "Stargate SG-1" ## [768] "Industria" ## [769] "Santiago" ## [770] "Maya" ## [771] "Lucky Loop" ## [772] "Atta Ants" ## [773] "Sluff Off!" ## [774] "Die Fugger" ## [775] "Winter Fury: The Battle of Tolvajärvi 1939" ## [776] "History of War" ## [777] "Kogge" ## [778] "The Lord of the Rings: Combat Hex Tradeable Miniatures Game" ## [779] "Global Powers" ## [780] "Maka Bana" ## [781] "Illuminati: Crime Lords" ## [782] "Anno 1503" ## [783] "Return of the Heroes" ## [784] "Coyote" ## [785] "UNO: Spider-Man" ## [786] "Yellowstone Park" ## [787] "Floriado" ## [788] "The Bridges of Shangri-La" ## [789] "Snail Race" ## [790] "Railroad Dice" ## [791] "Viva Topo!" ## [792] "Hey, That's My Fish!" ## [793] "Dungeoneer: Vault of the Fiends" ## [794] "San Juan" ## [795] "Spank the Monkey" ## [796] "Armadöra" ## [797] "Zauberschwert & Drachenei" ## [798] "Hoppla Lama" ## [799] "Alexandros" ## [800] "3D Labyrinth" ## [801] "Say What!?!" ## [802] "Top Speed" ## [803] "Wapi" ## [804] "Monopoly: NHL" ## [805] "Ludoviel" ## [806] "The Great Pacific War" ## [807] "Sorry! The Disney Edition" ## [808] "Hector and Achilles" ## [809] "Schwarzarbeit" ## [810] "Tempus Draconis" ## [811] "Odds'R" ## [812] "Crusader Rex" ## [813] "Age of Napoleon" ## [814] "Torches & Pitchforks" ## [815] "Dork Tower" ## [816] "Hybrid" ## [817] "Master and Commander: The Far Side of the World" ## [818] "Whistling Death" ## [819] "Ninja Burger" ## [820] "PDQ: The Pretty Darn Quick Word Game" ## [821] "Turbo" ## [822] "I Go!" ## [823] "Cannon" ## [824] "Cargo" ## [825] "The Haunting House" ## [826] "Austerlitz 1805: Napoleon's Greatest Victory" ## [827] "Wreckage" ## [828] "Diceland: Extra Space" ## [829] "Assyrian Wars" ## [830] "Monopoly: Disney" ## [831] "Tears of the Dragon" ## [832] "Brawling Battleships" ## [833] "Igloo Pop" ## [834] "Terra" ## [835] "Days of Decision III" ## [836] "Buzzword" ## [837] "Chief Herman's Next Big Thing" ## [838] "Jacob Marley, Esq." ## [839] "Flying Colors" ## [840] "Stoner Fluxx" ## [841] "Shocking Roulette" ## [842] "Frenzy" ## [843] "Call of Cthulhu: Collectible Card Game" ## [844] "Cranium Conga" ## [845] "IGOR: The Mad Scientist's Lament" ## [846] "Jenga Xtreme" ## [847] "Jenga Truth-or-Dare" ## [848] "BuyWord" ## [849] "Dancing Eggs" ## [850] "Buffy the Vampire Slayer CCG" ## [851] "Shazamm!" ## [852] "Coda" ## [853] "kuuduk" ## [854] "1 Stein + Co." ## [855] "The Lord of the Rings Labyrinth" ## [856] "Junkyard Races" ## [857] "Hansa" ## [858] "Sunken City" ## [859] "Oasis" ## [860] "Tongiaki: Journey into the Unknown" ## [861] "Cinq-O" ## [862] "Teenage Mutant Ninja Turtles Game" ## [863] "1777: The Year of the Hangman" ## [864] "The Three Days of Gettysburg (second edition)" ## [865] "Masquerade" ## [866] "18C2C: Manifest Destiny" ## [867] "Advanced European Theater of Operations" ## [868] "Marco Polo Expedition" ## [869] "Wordigo" ## [870] "Zitternix" ## [871] "Neopets TCG" ## [872] "Heroes Incorporated" ## [873] "Spy" ## [874] "Saga" ## [875] "Wings of War: Famous Aces" ## [876] "Ticket to Ride" ## [877] "Manga Manga" ## [878] "Revolution: The Dutch Revolt 1568-1648" ## [879] "Goa" ## [880] "Saint Petersburg" ## [881] "Saboteur" ## [882] "Weed!" ## [883] "Treasure Falls" ## [884] "Who? What? Where?" ## [885] "Oh, Pharaoh!" ## [886] "Lost Valley" ## [887] "Fifth Avenue" ## [888] "Daimyo" ## [889] "Privacy" ## [890] "Knock! Knock!" ## [891] "Dos Rios" ## [892] "FBI" ## [893] "Maharaja: The Game of Palace Building in India" ## [894] "Ribbit" ## [895] "Blue Moon" ## [896] "Adam & Eva" ## [897] "Ooga!" ## [898] "Iglu Iglu" ## [899] "Snatch" ## [900] "Indus" ## [901] "UNO: SpongeBob SquarePants" ## [902] "Cluzzle" ## [903] "War of the Ring (first edition)" ## [904] "Station Master" ## [905] "Horus" ## [906] "Russian Rails" ## [907] "Struggle of Empires" ## [908] "Gnostica" ## [909] "Greed Quest" ## [910] "Black Elephant" ## [911] "Ingenious" ## [912] "La Strada" ## [913] "Duell" ## [914] "Battle of the Bands: Encore Edition" ## [915] "Beer Money" ## [916] "¿Pasáran? The Spanish Civil War" ## [917] "Oriente" ## [918] "Ostrakon" ## [919] "Tuchulcha" ## [920] "Operation Michael" ## [921] "Gettysburg: Badges of Courage" ## [922] "Advanced Squad Leader: Starter Kit #1" ## [923] "Employee of the Month" ## [924] "Early American Chrononauts" ## [925] "Runebound (First Edition)" ## [926] "Au fil de l'épée" ## [927] "Clue Jr.: The Case of the Missing Cake" ## [928] "Marengo 1800" ## [929] "Wings of War: Watch Your Back!" ## [930] "Chez Goth" ## [931] "Santorini" ## [932] "Speculation" ## [933] "Seasons: The Calendar Rummy Game" ## [934] "LEGO Racers Super Speedway Game" ## [935] "Pokémon Master Trainer II" ## [936] "Axis & Allies: D-Day" ## [937] "Axis & Allies" ## [938] "Ignorant Armies: Iran-Iraq War" ## [939] "The Scrambled States of America" ## [940] "The Russian Campaign (fourth edition)" ## [941] "Fliegen klatschen" ## [942] "RISIKO! Master" ## [943] "Bitter Woods (fourth edition)" ## [944] "Farlander" ## [945] "Make 'n' Break" ## [946] "Berlin: Red Victory" ## [947] "Panther Line: Army Group North 1944" ## [948] "Monkey Madness" ## [949] "Group of Soviet Forces Germany" ## [950] "Saga" ## [951] "Marry, Date or Dump?" ## [952] "Risk: Godstorm" ## [953] "SiegeStones" ## [954] "Epic Armageddon" ## [955] "Duel Masters Trading Card Game" ## [956] "Camelot Legends" ## [957] "Tyrus" ## [958] "Victory & Honor" ## [959] "Football Champions" ## [960] "Betrayal at House on the Hill" ## [961] "Pyramidos" ## [962] "Why Did the Chicken...?" ## [963] "Poison Pot" ## [964] "Bittereinder" ## [965] "Gringo!" ## [966] "Memoir '44" ## [967] "Doom: The Boardgame" ## [968] "Barbarossa: Army Group North, 1941" ## [969] "Pirates of the Spanish Main" ## [970] "Hex Hex" ## [971] "Micropul" ## [972] "Victoria Cross" ## [973] "Panzer Grenadier: Desert Rats" ## [974] "Easy Come, Easy Go" ## [975] "Monopoly: America Special Edition" ## [976] "A Fearful Slaughter: The Battle of Shiloh" ## [977] "Apples to Apples Junior" ## [978] "Atlas & Zeus" ## [979] "Hacker: Deluxe Edition" ## [980] "CSI: Crime Scene Investigation Boardgame" ## [981] "Dancing Dice" ## [982] "Geist" ## [983] "Hellenes: Campaigns of the Peloponnesian War" ## [984] "Somethin' Fishy" ## [985] "Fishing for Terrorists" ## [986] "Dawn Under" ## [987] "Navia Dratp" ## [988] "Vapor's Gambit" ## [989] "Heart of Africa" ## [990] "Minotaur Lords" ## [991] "Jumpin' Java" ## [992] "Simply Suspects" ## [993] "Things..." ## [994] "Master Thieves" ## [995] "Swärje" ## [996] "Smugglers of the Galaxy" ## [997] "Borodino: Battle of the Moskova, 1812" ## [998] "ConHex" ## [999] "Boomtown" ## [1000] "Word Jam" ## [ reached getOption("max.print") -- omitted 6552 entries ] ``` --- # Today's data set ```r board_games$mechanic ``` ``` ## [1] "Hand Management" ## [2] "Auction/Bidding,Card Drafting,Hand Management,Route/Network Building,Set Collection" ## [3] "Card Drafting,Set Collection,Simultaneous Action Selection,Variable Phase Order,Variable Player Powers" ## [4] "Area Control / Area Influence,Dice Rolling,Hand Management,Modular Board,Partnerships" ## [5] "Hex-and-Counter" ## [6] "Area Control / Area Influence,Card Drafting,Hand Management,Route/Network Building" ## [7] "Auction/Bidding,Set Collection,Worker Placement" ## [8] "Set Collection" ## [9] "Hand Management,Set Collection" ## [10] "Set Collection" ## [11] "Auction/Bidding,Trading" ## [12] "Area Control / Area Influence,Auction/Bidding,Tile Placement" ## [13] "Pattern Building,Pattern Recognition,Route/Network Building,Tile Placement" ## [14] "Voting" ## [15] "Dice Rolling,Hand Management,Modular Board" ## [16] "Area Control / Area Influence,Card Drafting,Commodity Speculation,Modular Board,Tile Placement" ## [17] "Auction/Bidding,Tile Placement" ## [18] "Area Movement,Set Collection" ## [19] NA ## [20] "Auction/Bidding,Hand Management,Route/Network Building,Voting" ## [21] "Set Collection,Simultaneous Action Selection" ## [22] "Trick-taking" ## [23] "Area Control / Area Influence,Card Drafting" ## [24] "Auction/Bidding,Set Collection" ## [25] "Tile Placement" ## [26] "Hand Management,Pick-up and Deliver,Point to Point Movement" ## [27] "Dice Rolling" ## [28] "Area-Impulse" ## [29] "Action / Movement Programming,Point to Point Movement,Simultaneous Action Selection" ## [30] "Action Point Allowance System,Hand Management,Secret Unit Deployment" ## [31] NA ## [32] "Auction/Bidding" ## [33] "Take That,Variable Player Powers" ## [34] NA ## [35] NA ## [36] "Hand Management,Tile Placement" ## [37] "Simultaneous Action Selection" ## [38] "Set Collection,Trading" ## [39] "Dice Rolling,Hex-and-Counter,Modular Board,Secret Unit Deployment,Variable Player Powers" ## [40] "Stock Holding,Voting" ## [41] NA ## [42] "Betting/Wagering" ## [43] "Auction/Bidding" ## [44] NA ## [45] "Hand Management,Set Collection" ## [46] "Campaign / Battle Card Driven,Roll / Spin and Move" ## [47] NA ## [48] "Variable Player Powers" ## [49] "Area Control / Area Influence" ## [50] NA ## [51] "Variable Player Powers" ## [52] "Partnerships,Role Playing,Roll / Spin and Move,Variable Player Powers" ## [53] "Hand Management,Modular Board,Press Your Luck" ## [54] "Area Control / Area Influence,Tile Placement" ## [55] "Co-operative Play,Dice Rolling,Hand Management,Set Collection,Variable Player Powers" ## [56] "Hand Management,Modular Board" ## [57] "Area Control / Area Influence,Stock Holding" ## [58] "Hand Management,Take That" ## [59] "Auction/Bidding,Pick-up and Deliver" ## [60] "Area Control / Area Influence,Dice Rolling,Hand Management,Modular Board" ## [61] "Variable Player Powers" ## [62] NA ## [63] "Modular Board" ## [64] "Area Control / Area Influence,Auction/Bidding,Simultaneous Action Selection" ## [65] "Action Point Allowance System,Area Control / Area Influence,Tile Placement" ## [66] NA ## [67] "Modular Board,Route/Network Building" ## [68] "Dice Rolling,Pattern Recognition" ## [69] "Area Control / Area Influence,Campaign / Battle Card Driven,Rock-Paper-Scissors,Trading" ## [70] "Tile Placement" ## [71] NA ## [72] "Tile Placement" ## [73] "Hand Management,Set Collection" ## [74] "Auction/Bidding,Hand Management,Set Collection" ## [75] "Tile Placement,Worker Placement" ## [76] "Card Drafting,Hand Management,Modular Board,Point to Point Movement" ## [77] "Partnerships" ## [78] "Auction/Bidding,Set Collection" ## [79] "Dice Rolling,Secret Unit Deployment,Simulation" ## [80] "Memory,Roll / Spin and Move" ## [81] NA ## [82] "Set Collection" ## [83] "Campaign / Battle Card Driven,Simultaneous Action Selection" ## [84] NA ## [85] "Partnerships,Trick-taking" ## [86] "Area-Impulse,Auction/Bidding,Secret Unit Deployment" ## [87] "Auction/Bidding,Rock-Paper-Scissors" ## [88] "Dice Rolling,Simultaneous Action Selection" ## [89] "Set Collection" ## [90] "Hand Management,Set Collection" ## [91] "Point to Point Movement" ## [92] "Area Control / Area Influence,Card Drafting" ## [93] "Hand Management,Set Collection,Trading" ## [94] "Modular Board" ## [95] NA ## [96] "Set Collection,Trading" ## [97] "Area Control / Area Influence,Auction/Bidding,Dice Rolling" ## [98] "Area Control / Area Influence,Auction/Bidding" ## [99] NA ## [100] "Action Point Allowance System,Area Control / Area Influence,Area Movement,Auction/Bidding,Dice Rolling,Hand Management,Variable Player Powers" ## [101] NA ## [102] "Tile Placement" ## [103] "Auction/Bidding,Stock Holding" ## [104] "Memory" ## [105] NA ## [106] "Tile Placement" ## [107] "Tile Placement" ## [108] NA ## [109] "Tile Placement" ## [110] "Area Control / Area Influence,Area Movement,Partnerships" ## [111] "Card Drafting,Dice Rolling,Set Collection" ## [112] NA ## [113] "Hand Management,Set Collection" ## [114] "Area Movement" ## [115] "Auction/Bidding,Pick-up and Deliver" ## [116] NA ## [117] "Modular Board,Pick-up and Deliver,Set Collection" ## [118] "Roll / Spin and Move" ## [119] "Route/Network Building,Stock Holding,Tile Placement" ## [120] "Action / Movement Programming,Action Point Allowance System,Variable Player Powers" ## [121] "Set Collection" ## [122] "Trick-taking" ## [123] "Memory" ## [124] NA ## [125] "Hand Management" ## [126] NA ## [127] "Hand Management" ## [128] "Area Control / Area Influence,Modular Board,Tile Placement" ## [129] "Auction/Bidding" ## [130] "Auction/Bidding,Tile Placement" ## [131] "Auction/Bidding,Pick-up and Deliver,Tile Placement" ## [132] "Auction/Bidding,Dice Rolling,Grid Movement,Pick-up and Deliver,Set Collection,Trading" ## [133] "Auction/Bidding" ## [134] "Auction/Bidding,Set Collection,Variable Player Powers" ## [135] "Hand Management" ## [136] "Set Collection,Trading" ## [137] "Modular Board" ## [138] "Action Point Allowance System,Campaign / Battle Card Driven" ## [139] "Auction/Bidding,Set Collection" ## [140] "Set Collection" ## [141] "Variable Player Powers" ## [142] "Grid Movement" ## [143] "Betting/Wagering,Roll / Spin and Move" ## [144] "Partnerships" ## [145] "Set Collection" ## [146] "Area Control / Area Influence,Tile Placement" ## [147] "Modular Board,Tile Placement" ## [148] "Auction/Bidding" ## [149] "Set Collection" ## [150] "Modular Board" ## [151] "Area Control / Area Influence,Simultaneous Action Selection" ## [152] NA ## [153] "Partnerships,Secret Unit Deployment" ## [154] "Area Control / Area Influence,Tile Placement" ## [155] "Dice Rolling,Hand Management,Point to Point Movement" ## [156] "Hex-and-Counter" ## [157] "Campaign / Battle Card Driven,Partnerships,Trading" ## [158] "Role Playing" ## [159] "Pick-up and Deliver" ## [160] "Roll / Spin and Move" ## [161] "Dice Rolling,Set Collection" ## [162] "Tile Placement" ## [163] "Co-operative Play" ## [164] "Variable Player Powers" ## [165] "Auction/Bidding,Crayon Rail System,Stock Holding" ## [166] NA ## [167] "Dice Rolling" ## [168] NA ## [169] "Hex-and-Counter" ## [170] "Campaign / Battle Card Driven,Dice Rolling,Point to Point Movement" ## [171] "Area Control / Area Influence,Area Movement,Auction/Bidding,Dice Rolling,Variable Phase Order" ## [172] NA ## [173] NA ## [174] NA ## [175] "Card Drafting,Dice Rolling,Hand Management,Take That,Variable Player Powers" ## [176] "Dice Rolling" ## [177] "Set Collection,Take That" ## [178] "Hex-and-Counter" ## [179] "Betting/Wagering,Roll / Spin and Move" ## [180] NA ## [181] "Campaign / Battle Card Driven" ## [182] "Grid Movement,Variable Player Powers" ## [183] "Auction/Bidding,Set Collection" ## [184] "Auction/Bidding,Set Collection,Variable Player Powers" ## [185] "Campaign / Battle Card Driven,Hand Management" ## [186] "Pattern Building,Pattern Recognition" ## [187] "Dice Rolling,Modular Board,Role Playing" ## [188] "Hand Management" ## [189] "Action Point Allowance System,Set Collection,Variable Player Powers" ## [190] "Dice Rolling,Hex-and-Counter,Simulation" ## [191] "Modular Board,Tile Placement" ## [192] "Dice Rolling,Variable Player Powers" ## [193] "Dice Rolling,Memory,Press Your Luck,Trading" ## [194] "Modular Board,Pick-up and Deliver,Tile Placement" ## [195] "Area Enclosure,Auction/Bidding,Modular Board" ## [196] "Grid Movement" ## [197] "Rock-Paper-Scissors,Tile Placement" ## [198] "Tile Placement" ## [199] "Paper-and-Pencil,Secret Unit Deployment" ## [200] "Set Collection" ## [201] "Set Collection,Trading" ## [202] "Roll / Spin and Move" ## [203] "Area Enclosure,Tile Placement" ## [204] "Point to Point Movement,Rock-Paper-Scissors,Roll / Spin and Move" ## [205] "Campaign / Battle Card Driven" ## [206] "Dice Rolling,Grid Movement,Hand Management,Modular Board,Roll / Spin and Move" ## [207] NA ## [208] "Auction/Bidding,Card Drafting,Hand Management" ## [209] "Take That" ## [210] "Area Control / Area Influence,Auction/Bidding,Card Drafting,Hand Management" ## [211] "Area Control / Area Influence,Tile Placement" ## [212] "Modular Board,Set Collection" ## [213] "Betting/Wagering" ## [214] "Hand Management" ## [215] "Action Point Allowance System,Area Control / Area Influence,Auction/Bidding,Variable Player Powers" ## [216] "Partnerships,Tile Placement,Variable Player Powers" ## [217] "Dice Rolling,Roll / Spin and Move" ## [218] NA ## [219] "Hand Management,Press Your Luck,Tile Placement" ## [220] "Auction/Bidding" ## [221] "Take That" ## [222] "Dice Rolling,Hand Management,Simultaneous Action Selection" ## [223] "Set Collection" ## [224] "Area Control / Area Influence,Area Movement" ## [225] "Action Point Allowance System" ## [226] "Dice Rolling,Pattern Building" ## [227] "Roll / Spin and Move" ## [228] "Tile Placement" ## [229] NA ## [230] "Hand Management" ## [231] "Card Drafting,Set Collection" ## [232] "Variable Player Powers" ## [233] "Area Movement,Dice Rolling,Simulation" ## [234] "Hex-and-Counter" ## [235] "Auction/Bidding,Route/Network Building" ## [236] "Grid Movement,Tile Placement" ## [237] "Area Control / Area Influence,Hand Management" ## [238] NA ## [239] "Hand Management,Modular Board,Pick-up and Deliver,Tile Placement" ## [240] NA ## [241] "Roll / Spin and Move" ## [242] NA ## [243] "Co-operative Play,Singing" ## [244] "Auction/Bidding,Hand Management,Set Collection,Simultaneous Action Selection" ## [245] "Campaign / Battle Card Driven,Point to Point Movement" ## [246] NA ## [247] NA ## [248] "Dice Rolling,Rock-Paper-Scissors" ## [249] "Modular Board,Role Playing,Tile Placement" ## [250] "Set Collection" ## [251] "Card Drafting,Pattern Recognition,Set Collection" ## [252] NA ## [253] NA ## [254] "Roll / Spin and Move" ## [255] "Route/Network Building" ## [256] "Set Collection" ## [257] "Pattern Recognition" ## [258] NA ## [259] "Hex-and-Counter" ## [260] "Action Point Allowance System,Modular Board,Role Playing,Tile Placement,Variable Player Powers" ## [261] NA ## [262] "Storytelling" ## [263] "Partnerships,Roll / Spin and Move" ## [264] "Tile Placement" ## [265] "Chit-Pull System,Dice Rolling,Hex-and-Counter,Simulation" ## [266] "Auction/Bidding,Roll / Spin and Move,Set Collection,Trading" ## [267] "Dice Rolling,Hand Management" ## [268] "Dice Rolling,Modular Board" ## [269] "Action Point Allowance System,Pick-up and Deliver,Variable Player Powers" ## [270] "Action Point Allowance System,Area Control / Area Influence,Area Enclosure,Grid Movement,Tile Placement" ## [271] "Tile Placement" ## [272] "Auction/Bidding,Set Collection" ## [273] "Auction/Bidding,Commodity Speculation,Trading" ## [274] "Modular Board,Set Collection,Tile Placement,Variable Player Powers" ## [275] NA ## [276] "Dice Rolling,Hand Management,Pick-up and Deliver,Simultaneous Action Selection" ## [277] "Point to Point Movement,Variable Player Powers" ## [278] "Chit-Pull System,Hex-and-Counter" ## [279] "Action Point Allowance System,Dice Rolling,Hex-and-Counter" ## [280] "Auction/Bidding,Roll / Spin and Move,Set Collection,Trading" ## [281] "Roll / Spin and Move" ## [282] "Auction/Bidding,Roll / Spin and Move,Set Collection,Stock Holding,Trading" ## [283] "Storytelling" ## [284] "Variable Phase Order" ## [285] "Dice Rolling" ## [286] "Hand Management,Worker Placement" ## [287] "Route/Network Building" ## [288] "Hand Management" ## [289] "Dice Rolling" ## [290] "Hand Management,Modular Board,Pick-up and Deliver" ## [291] "Hand Management,Take That" ## [292] "Set Collection,Tile Placement" ## [293] "Commodity Speculation,Set Collection,Stock Holding" ## [294] "Auction/Bidding,Set Collection" ## [295] "Modular Board,Role Playing,Simultaneous Action Selection" ## [296] "Area Movement,Hand Management,Memory,Secret Unit Deployment,Simultaneous Action Selection,Variable Player Powers" ## [297] "Set Collection" ## [298] NA ## [299] "Area Enclosure,Tile Placement" ## [300] "Trading" ## [301] "Auction/Bidding,Partnerships" ## [302] "Auction/Bidding" ## [303] "Area Control / Area Influence,Auction/Bidding,Tile Placement" ## [304] "Dice Rolling,Player Elimination" ## [305] "Area Enclosure,Hand Management,Tile Placement" ## [306] "Auction/Bidding,Hand Management" ## [307] "Hex-and-Counter" ## [308] "Auction/Bidding" ## [309] NA ## [310] "Pick-up and Deliver,Role Playing,Roll / Spin and Move,Set Collection" ## [311] "Area Movement" ## [312] "Hand Management,Player Elimination,Variable Player Powers" ## [313] "Campaign / Battle Card Driven,Player Elimination,Roll / Spin and Move,Variable Player Powers" ## [314] "Dice Rolling,Grid Movement,Player Elimination" ## [315] "Action / Movement Programming,Action Point Allowance System,Area Control / Area Influence,Area Movement,Simultaneous Action Selection,Variable Phase Order" ## [316] "Hex-and-Counter" ## [317] "Trick-taking" ## [318] "Hand Management" ## [319] "Roll / Spin and Move" ## [320] "Card Drafting,Hand Management" ## [321] "Dice Rolling,Variable Player Powers" ## [322] "Action / Movement Programming,Hex-and-Counter,Simulation,Simultaneous Action Selection" ## [323] "Card Drafting,Hand Management,Take That" ## [324] "Card Drafting,Route/Network Building,Simultaneous Action Selection,Stock Holding" ## [325] "Roll / Spin and Move" ## [326] "Campaign / Battle Card Driven,Point to Point Movement" ## [327] NA ## [328] "Set Collection" ## [329] "Area Enclosure,Modular Board" ## [330] "Area Movement,Memory,Secret Unit Deployment" ## [331] NA ## [332] "Auction/Bidding,Roll / Spin and Move,Set Collection,Trading" ## [333] "Hand Management,Partnerships,Trick-taking" ## [334] "Hex-and-Counter" ## [335] "Campaign / Battle Card Driven" ## [336] "Dice Rolling,Hex-and-Counter" ## [337] "Hex-and-Counter" ## [338] "Dice Rolling,Hex-and-Counter" ## [339] "Dice Rolling,Grid Movement,Roll / Spin and Move" ## [340] "Hand Management,Set Collection" ## [341] "Hand Management" ## [342] "Action Point Allowance System,Dice Rolling,Variable Player Powers" ## [343] "Dice Rolling,Roll / Spin and Move,Set Collection" ## [344] "Action Point Allowance System,Hand Management,Variable Player Powers" ## [345] "Memory,Set Collection" ## [346] "Area Movement,Dice Rolling" ## [347] "Area Movement,Co-operative Play,Grid Movement,Roll / Spin and Move" ## [348] "Variable Player Powers" ## [349] "Action Point Allowance System,Set Collection" ## [350] "Campaign / Battle Card Driven,Modular Board" ## [351] "Auction/Bidding,Roll / Spin and Move" ## [352] "Dice Rolling" ## [353] "Line Drawing,Tile Placement" ## [354] NA ## [355] "Auction/Bidding,Card Drafting,Hand Management,Set Collection" ## [356] "Partnerships,Roll / Spin and Move,Voting" ## [357] "Campaign / Battle Card Driven,Dice Rolling,Modular Board,Role Playing,Roll / Spin and Move,Variable Player Powers" ## [358] "Hand Management,Set Collection,Trick-taking,Voting" ## [359] "Area Movement,Dice Rolling,Rock-Paper-Scissors,Set Collection,Simultaneous Action Selection,Trading" ## [360] "Hand Management,Set Collection,Trading" ## [361] "Area Enclosure,Modular Board" ## [362] "Hand Management,Set Collection,Variable Player Powers" ## [363] "Area Movement,Area-Impulse,Campaign / Battle Card Driven,Dice Rolling,Hand Management,Secret Unit Deployment,Simultaneous Action Selection" ## [364] "Action / Movement Programming,Dice Rolling,Hand Management,Set Collection,Take That,Trading" ## [365] "Roll / Spin and Move" ## [366] NA ## [367] "Hand Management,Simultaneous Action Selection" ## [368] NA ## [369] "Action / Movement Programming,Area Control / Area Influence,Pick-up and Deliver,Set Collection,Simultaneous Action Selection" ## [370] "Co-operative Play,Modular Board,Role Playing,Roll / Spin and Move,Tile Placement" ## [371] "Point to Point Movement" ## [372] "Commodity Speculation,Dice Rolling" ## [373] NA ## [374] NA ## [375] "Action Point Allowance System,Variable Player Powers" ## [376] "Area Movement,Simulation,Variable Player Powers" ## [377] "Memory,Press Your Luck" ## [378] "Roll / Spin and Move,Set Collection" ## [379] "Auction/Bidding,Hand Management,Simultaneous Action Selection" ## [380] NA ## [381] "Area Control / Area Influence,Dice Rolling,Set Collection,Trading,Variable Player Powers" ## [382] "Hand Management,Variable Player Powers" ## [383] "Hand Management,Partnerships,Player Elimination,Take That,Variable Player Powers" ## [384] "Dice Rolling,Hand Management,Modular Board,Route/Network Building,Trading" ## [385] "Dice Rolling,Roll / Spin and Move" ## [386] "Card Drafting,Memory" ## [387] "Hex-and-Counter,Modular Board" ## [388] "Hand Management" ## [389] "Area Movement,Dice Rolling,Roll / Spin and Move" ## [390] NA ## [391] "Area-Impulse,Hex-and-Counter" ## [392] "Action Point Allowance System" ## [393] "Pattern Recognition" ## [394] "Set Collection" ## [395] "Hand Management" ## [396] NA ## [397] "Press Your Luck" ## [398] "Tile Placement" ## [399] "Card Drafting,Dice Rolling,Take That,Trading,Variable Player Powers" ## [400] "Set Collection,Trading" ## [401] "Auction/Bidding,Dice Rolling,Player Elimination,Route/Network Building,Tile Placement" ## [402] "Auction/Bidding,Modular Board,Set Collection,Tile Placement,Worker Placement" ## [403] "Dice Rolling,Variable Player Powers" ## [404] "Auction/Bidding,Stock Holding" ## [405] "Pick-up and Deliver" ## [406] NA ## [407] NA ## [408] NA ## [409] "Hand Management,Partnerships,Player Elimination,Secret Unit Deployment,Set Collection,Trading,Variable Player Powers" ## [410] "Variable Player Powers" ## [411] "Hand Management,Set Collection" ## [412] "Dice Rolling,Roll / Spin and Move" ## [413] "Area Enclosure,Auction/Bidding,Set Collection,Tile Placement" ## [414] "Hand Management,Simultaneous Action Selection" ## [415] "Dice Rolling,Modular Board,Partnerships" ## [416] "Action Point Allowance System,Area Control / Area Influence,Modular Board" ## [417] "Roll / Spin and Move,Trading" ## [418] NA ## [419] NA ## [420] "Modular Board,Roll / Spin and Move,Trading" ## [421] "Hand Management" ## [422] "Modular Board,Route/Network Building,Tile Placement" ## [423] "Line Drawing,Pick-up and Deliver" ## [424] "Area Control / Area Influence,Area Movement,Campaign / Battle Card Driven,Dice Rolling" ## [425] "Auction/Bidding,Take That" ## [426] "Area Movement" ## [427] "Tile Placement" ## [428] NA ## [429] "Hand Management" ## [430] "Dice Rolling,Hex-and-Counter" ## [431] "Pattern Building,Variable Player Powers" ## [432] "Auction/Bidding" ## [433] NA ## [434] "Pick-up and Deliver" ## [435] "Pattern Building,Tile Placement" ## [436] "Action Point Allowance System,Campaign / Battle Card Driven,Modular Board" ## [437] "Auction/Bidding,Card Drafting,Set Collection" ## [438] "Area Control / Area Influence,Area Movement" ## [439] "Area Control / Area Influence,Tile Placement" ## [440] "Dice Rolling,Route/Network Building,Trading" ## [441] "Pick-up and Deliver,Trading" ## [442] "Hand Management" ## [443] "Set Collection" ## [444] "Card Drafting,Set Collection" ## [445] "Action Point Allowance System" ## [446] "Acting,Co-operative Play,Hand Management,Paper-and-Pencil" ## [447] NA ## [448] "Pattern Building,Tile Placement" ## [449] "Pattern Recognition" ## [450] "Hand Management,Memory" ## [451] "Auction/Bidding,Set Collection" ## [452] "Set Collection,Simultaneous Action Selection" ## [453] "Set Collection" ## [454] "Area Control / Area Influence,Deck / Pool Building,Hand Management" ## [455] "Action Point Allowance System,Area Control / Area Influence,Hand Management,Point to Point Movement" ## [456] "Roll / Spin and Move" ## [457] NA ## [458] "Co-operative Play,Pattern Recognition" ## [459] "Area Control / Area Influence,Hand Management,Tile Placement" ## [460] "Variable Player Powers" ## [461] "Hand Management" ## [462] "Auction/Bidding,Stock Holding" ## [463] "Hand Management,Pattern Building" ## [464] "Betting/Wagering,Hand Management" ## [465] "Set Collection,Take That" ## [466] "Action Point Allowance System,Area Movement,Co-operative Play,Hand Management,Memory,Partnerships,Secret Unit Deployment,Tile Placement" ## [467] "Hand Management" ## [468] "Route/Network Building,Stock Holding,Tile Placement" ## [469] "Grid Movement" ## [470] "Memory,Set Collection" ## [471] "Area Control / Area Influence,Area Enclosure" ## [472] "Pattern Building,Point to Point Movement" ## [473] "Voting" ## [474] NA ## [475] "Modular Board,Roll / Spin and Move" ## [476] "Variable Player Powers" ## [477] "Campaign / Battle Card Driven,Hand Management,Secret Unit Deployment" ## [478] "Tile Placement" ## [479] NA ## [480] "Trick-taking" ## [481] "Rock-Paper-Scissors,Simultaneous Action Selection" ## [482] "Roll / Spin and Move" ## [483] "Roll / Spin and Move,Set Collection" ## [484] "Dice Rolling,Hex-and-Counter" ## [485] "Dice Rolling,Hex-and-Counter,Secret Unit Deployment" ## [486] "Roll / Spin and Move" ## [487] "Tile Placement" ## [488] "Area Movement,Dice Rolling,Simulation" ## [489] NA ## [490] NA ## [491] "Dice Rolling,Variable Player Powers" ## [492] "Simultaneous Action Selection" ## [493] "Pattern Building" ## [494] NA ## [495] "Hex-and-Counter" ## [496] NA ## [497] "Dice Rolling,Pattern Building,Pattern Recognition" ## [498] NA ## [499] "Dice Rolling" ## [500] "Modular Board,Partnerships,Role Playing,Tile Placement,Variable Player Powers" ## [501] "Modular Board" ## [502] "Hand Management,Tile Placement" ## [503] "Role Playing" ## [504] "Acting,Singing" ## [505] "Acting,Role Playing,Storytelling" ## [506] "Simulation" ## [507] "Pattern Building" ## [508] "Hex-and-Counter" ## [509] "Hand Management" ## [510] "Set Collection,Trading" ## [511] "Area Control / Area Influence,Auction/Bidding" ## [512] "Auction/Bidding,Tile Placement" ## [513] "Route/Network Building,Tile Placement" ## [514] "Partnerships" ## [515] NA ## [516] "Area Movement,Dice Rolling,Point to Point Movement" ## [517] "Roll / Spin and Move,Trading" ## [518] "Roll / Spin and Move" ## [519] "Tile Placement" ## [520] "Auction/Bidding,Roll / Spin and Move,Set Collection,Trading" ## [521] "Simultaneous Action Selection" ## [522] "Hex-and-Counter,Simulation" ## [523] "Dice Rolling,Memory" ## [524] "Partnerships" ## [525] "Dice Rolling,Modular Board,Tile Placement" ## [526] "Tile Placement" ## [527] NA ## [528] "Pick-up and Deliver,Simulation" ## [529] "Action Point Allowance System,Dice Rolling,Hand Management,Modular Board,Tile Placement,Variable Player Powers" ## [530] "Hand Management" ## [531] "Action / Movement Programming,Dice Rolling,Hex-and-Counter,Simulation" ## [532] "Tile Placement" ## [533] "Auction/Bidding,Route/Network Building,Stock Holding,Tile Placement" ## [534] NA ## [535] "Hand Management" ## [536] "Hex-and-Counter" ## [537] "Memory" ## [538] "Hand Management" ## [539] "Hand Management" ## [540] "Hand Management,Set Collection" ## [541] "Area Enclosure,Hand Management,Modular Board" ## [542] "Roll / Spin and Move" ## [543] "Betting/Wagering,Memory,Set Collection" ## [544] "Auction/Bidding,Roll / Spin and Move,Set Collection,Trading" ## [545] "Area Control / Area Influence" ## [546] "Partnerships,Voting" ## [547] "Set Collection,Simultaneous Action Selection" ## [548] "Card Drafting,Set Collection" ## [549] "Betting/Wagering,Dice Rolling,Modular Board" ## [550] NA ## [551] "Action Point Allowance System,Hand Management,Modular Board,Tile Placement" ## [552] "Card Drafting,Set Collection" ## [553] "Hex-and-Counter" ## [554] "Dice Rolling,Roll / Spin and Move" ## [555] "Area Control / Area Influence,Route/Network Building" ## [556] "Modular Board" ## [557] "Hand Management,Route/Network Building" ## [558] "Area Movement,Co-operative Play,Line Drawing,Modular Board,Pick-up and Deliver" ## [559] "Hand Management,Set Collection,Tile Placement" ## [560] "Set Collection" ## [561] "Dice Rolling" ## [562] "Dice Rolling,Grid Movement,Modular Board,Partnerships,Player Elimination,Variable Player Powers" ## [563] "Betting/Wagering,Commodity Speculation,Hand Management,Set Collection" ## [564] "Betting/Wagering" ## [565] "Hand Management,Simultaneous Action Selection" ## [566] "Area Movement,Simulation" ## [567] "Hand Management,Set Collection" ## [568] "Hand Management" ## [569] "Hex-and-Counter,Simulation" ## [570] "Tile Placement" ## [571] "Hex-and-Counter,Simulation" ## [572] "Action Point Allowance System,Area Movement,Dice Rolling,Secret Unit Deployment" ## [573] "Campaign / Battle Card Driven,Card Drafting,Player Elimination,Take That,Variable Player Powers" ## [574] "Dice Rolling,Memory,Roll / Spin and Move" ## [575] "Card Drafting,Hand Management,Set Collection,Tile Placement" ## [576] "Set Collection,Take That" ## [577] "Action Point Allowance System,Dice Rolling,Hex-and-Counter,Secret Unit Deployment" ## [578] "Card Drafting,Set Collection" ## [579] "Action / Movement Programming,Hand Management,Secret Unit Deployment,Simultaneous Action Selection,Worker Placement" ## [580] "Campaign / Battle Card Driven,Modular Board" ## [581] "Modular Board" ## [582] "Point to Point Movement,Roll / Spin and Move" ## [583] "Area-Impulse" ## [584] "Co-operative Play,Dice Rolling,Modular Board,Role Playing,Variable Player Powers" ## [585] NA ## [586] "Hex-and-Counter" ## [587] "Hand Management,Set Collection" ## [588] "Pattern Recognition" ## [589] "Area Enclosure,Hand Management,Tile Placement" ## [590] "Acting,Line Drawing,Paper-and-Pencil,Partnerships,Storytelling" ## [591] "Area Movement,Variable Player Powers" ## [592] "Area Movement,Auction/Bidding,Hand Management,Memory,Player Elimination,Simultaneous Action Selection,Variable Player Powers" ## [593] "Hand Management,Pattern Building,Pattern Recognition" ## [594] "Dice Rolling,Roll / Spin and Move" ## [595] "Hex-and-Counter,Simulation" ## [596] "Point to Point Movement,Route/Network Building,Tile Placement" ## [597] "Dice Rolling,Modular Board,Point to Point Movement,Press Your Luck" ## [598] "Dice Rolling,Hex-and-Counter,Modular Board" ## [599] "Modular Board,Pick-up and Deliver" ## [600] "Memory" ## [601] "Press Your Luck,Roll / Spin and Move" ## [602] "Area Movement,Dice Rolling,Hex-and-Counter,Point to Point Movement,Secret Unit Deployment,Simulation" ## [603] "Hex-and-Counter" ## [604] "Action Point Allowance System,Dice Rolling,Role Playing,Variable Player Powers" ## [605] NA ## [606] "Action Point Allowance System,Card Drafting,Set Collection" ## [607] "Dice Rolling,Variable Player Powers" ## [608] "Chit-Pull System,Hex-and-Counter" ## [609] "Dice Rolling,Paper-and-Pencil,Voting" ## [610] "Area Enclosure,Tile Placement" ## [611] "Dice Rolling,Hex-and-Counter,Simulation" ## [612] "Dice Rolling" ## [613] NA ## [614] NA ## [615] "Dice Rolling,Trading,Variable Player Powers" ## [616] NA ## [617] "Storytelling" ## [618] "Action Point Allowance System,Campaign / Battle Card Driven,Hand Management,Point to Point Movement" ## [619] "Chit-Pull System,Dice Rolling,Hex-and-Counter,Simulation" ## [620] "Action Point Allowance System,Card Drafting,Set Collection" ## [621] "Pattern Building" ## [622] "Dice Rolling,Variable Player Powers" ## [623] "Crayon Rail System,Pick-up and Deliver,Route/Network Building" ## [624] "Action Point Allowance System,Dice Rolling,Variable Player Powers" ## [625] "Campaign / Battle Card Driven,Hand Management,Secret Unit Deployment" ## [626] "Campaign / Battle Card Driven,Hand Management,Secret Unit Deployment" ## [627] "Roll / Spin and Move" ## [628] "Campaign / Battle Card Driven,Dice Rolling,Rock-Paper-Scissors,Secret Unit Deployment,Variable Phase Order,Variable Player Powers" ## [629] "Memory,Modular Board,Roll / Spin and Move,Set Collection" ## [630] NA ## [631] "Set Collection" ## [632] "Action Point Allowance System,Dice Rolling,Secret Unit Deployment" ## [633] "Modular Board,Secret Unit Deployment" ## [634] "Hand Management,Point to Point Movement" ## [635] "Dice Rolling,Role Playing" ## [636] "Memory,Set Collection" ## [637] "Action Point Allowance System,Dice Rolling,Hand Management,Variable Player Powers" ## [638] "Action Point Allowance System,Area Movement,Dice Rolling,Player Elimination,Point to Point Movement,Set Collection,Trading" ## [639] "Hex-and-Counter,Simulation" ## [640] "Dice Rolling,Modular Board,Set Collection,Trading" ## [641] "Area Control / Area Influence,Tile Placement" ## [642] "Roll / Spin and Move,Voting" ## [643] "Dice Rolling,Roll / Spin and Move" ## [644] "Tile Placement" ## [645] "Card Drafting,Hand Management,Memory,Secret Unit Deployment" ## [646] "Pattern Recognition,Simultaneous Action Selection" ## [647] "Secret Unit Deployment" ## [648] "Partnerships" ## [649] "Campaign / Battle Card Driven,Roll / Spin and Move,Variable Player Powers" ## [650] "Chit-Pull System,Hex-and-Counter" ## [651] "Storytelling,Voting" ## [652] "Hex-and-Counter" ## [653] "Action Point Allowance System,Campaign / Battle Card Driven,Hand Management,Modular Board,Partnerships,Pick-up and Deliver" ## [654] "Dice Rolling,Press Your Luck" ## [655] NA ## [656] "Dice Rolling,Simultaneous Action Selection" ## [657] "Pattern Recognition" ## [658] "Dice Rolling,Roll / Spin and Move" ## [659] "Dice Rolling,Hand Management,Roll / Spin and Move,Simultaneous Action Selection" ## [660] "Action Point Allowance System,Dice Rolling" ## [661] "Hand Management" ## [662] NA ## [663] "Secret Unit Deployment" ## [664] NA ## [665] "Dice Rolling,Hand Management" ## [666] "Dice Rolling,Hand Management" ## [667] "Dice Rolling,Hex-and-Counter" ## [668] "Dice Rolling,Hex-and-Counter" ## [669] "Dice Rolling,Hex-and-Counter,Modular Board,Secret Unit Deployment,Simulation" ## [670] "Dice Rolling,Hex-and-Counter,Secret Unit Deployment,Simulation" ## [671] "Chit-Pull System,Hex-and-Counter" ## [672] "Dice Rolling,Set Collection" ## [673] "Hand Management,Secret Unit Deployment" ## [674] "Dice Rolling,Hex-and-Counter,Secret Unit Deployment,Simulation" ## [675] "Dice Rolling,Hex-and-Counter,Secret Unit Deployment" ## [676] "Dice Rolling,Hex-and-Counter,Secret Unit Deployment,Simulation" ## [677] "Auction/Bidding,Roll / Spin and Move,Set Collection,Trading" ## [678] "Hand Management" ## [679] "Commodity Speculation,Pattern Building,Pick-up and Deliver,Tile Placement" ## [680] "Trick-taking" ## [681] "Action / Movement Programming,Hand Management,Player Elimination,Simulation,Variable Phase Order" ## [682] "Auction/Bidding,Route/Network Building,Stock Holding,Tile Placement" ## [683] NA ## [684] "Co-operative Play" ## [685] "Pattern Building" ## [686] "Hand Management" ## [687] "Hex-and-Counter,Secret Unit Deployment,Simulation" ## [688] "Roll / Spin and Move" ## [689] NA ## [690] "Auction/Bidding,Dice Rolling,Modular Board,Simulation" ## [691] "Hand Management,Roll / Spin and Move" ## [692] "Roll / Spin and Move" ## [693] "Memory" ## [694] "Dice Rolling,Paper-and-Pencil" ## [695] "Dice Rolling,Roll / Spin and Move" ## [696] "Dice Rolling,Modular Board,Partnerships,Variable Player Powers" ## [697] "Campaign / Battle Card Driven,Dice Rolling,Point to Point Movement,Variable Player Powers" ## [698] "Memory,Set Collection" ## [699] "Hex-and-Counter" ## [700] "Action Point Allowance System,Dice Rolling,Partnerships,Roll / Spin and Move" ## [701] "Modular Board,Secret Unit Deployment,Tile Placement" ## [702] "Hand Management" ## [703] "Hex-and-Counter" ## [704] "Pattern Recognition,Set Collection" ## [705] NA ## [706] "Tile Placement" ## [707] "Action Point Allowance System,Auction/Bidding,Voting" ## [708] "Dice Rolling" ## [709] NA ## [710] NA ## [711] "Hand Management,Modular Board,Secret Unit Deployment,Take That" ## [712] "Acting,Betting/Wagering,Co-operative Play,Roll / Spin and Move,Singing" ## [713] "Hex-and-Counter" ## [714] "Hand Management,Set Collection" ## [715] "Pattern Building,Tile Placement" ## [716] "Card Drafting,Dice Rolling,Paper-and-Pencil,Roll / Spin and Move" ## [717] "Area Control / Area Influence,Area Enclosure,Tile Placement" ## [718] "Area Control / Area Influence,Set Collection,Tile Placement" ## [719] "Hand Management" ## [720] "Auction/Bidding" ## [721] "Dice Rolling,Variable Player Powers" ## [722] "Dice Rolling,Hex-and-Counter" ## [723] "Hand Management,Memory,Secret Unit Deployment" ## [724] "Grid Movement,Modular Board" ## [725] "Voting" ## [726] "Dice Rolling,Roll / Spin and Move,Set Collection,Variable Player Powers" ## [727] "Co-operative Play,Roll / Spin and Move,Secret Unit Deployment,Variable Player Powers" ## [728] "Co-operative Play,Roll / Spin and Move" ## [729] NA ## [730] "Hex-and-Counter" ## [731] "Area Enclosure,Pattern Recognition" ## [732] "Co-operative Play,Hand Management,Memory" ## [733] "Grid Movement,Pattern Building" ## [734] "Dice Rolling,Hex-and-Counter" ## [735] "Hand Management,Set Collection,Variable Player Powers" ## [736] "Campaign / Battle Card Driven,Point to Point Movement" ## [737] NA ## [738] "Hand Management,Route/Network Building,Tile Placement" ## [739] "Hand Management,Route/Network Building,Tile Placement" ## [740] NA ## [741] "Dice Rolling,Role Playing" ## [742] "Auction/Bidding,Route/Network Building,Stock Holding,Tile Placement" ## [743] NA ## [744] NA ## [745] "Memory" ## [746] "Auction/Bidding" ## [747] "Hex-and-Counter" ## [748] "Area Movement,Dice Rolling,Roll / Spin and Move" ## [749] "Hand Management,Trick-taking" ## [750] "Campaign / Battle Card Driven,Card Drafting,Hand Management" ## [751] "Modular Board,Tile Placement" ## [752] "Area Movement,Area-Impulse,Dice Rolling,Simulation" ## [753] "Roll / Spin and Move" ## [754] "Auction/Bidding,Dice Rolling,Roll / Spin and Move,Set Collection,Trading" ## [755] "Area Control / Area Influence,Auction/Bidding,Dice Rolling,Variable Player Powers" ## [756] "Modular Board,Route/Network Building,Tile Placement" ## [757] "Area Control / Area Influence,Variable Player Powers" ## [758] "Roll / Spin and Move" ## [759] "Hand Management,Paper-and-Pencil" ## [760] "Dice Rolling,Set Collection,Simulation,Variable Player Powers" ## [761] "Storytelling" ## [762] NA ## [763] "Card Drafting,Dice Rolling,Point to Point Movement,Role Playing,Variable Player Powers" ## [764] "Action Point Allowance System,Area Movement,Pick-up and Deliver" ## [765] NA ## [766] "Area Control / Area Influence,Area Movement,Campaign / Battle Card Driven,Dice Rolling" ## [767] "Point to Point Movement" ## [768] "Auction/Bidding,Hand Management" ## [769] "Area Control / Area Influence,Auction/Bidding,Commodity Speculation,Tile Placement" ## [770] "Area Control / Area Influence,Auction/Bidding" ## [771] "Dice Rolling" ## [772] "Modular Board,Pick-up and Deliver,Tile Placement" ## [773] "Trick-taking" ## [774] "Commodity Speculation" ## [775] "Chit-Pull System,Dice Rolling,Hex-and-Counter,Variable Phase Order" ## [776] "Campaign / Battle Card Driven,Card Drafting,Hand Management" ## [777] "Auction/Bidding,Pick-up and Deliver" ## [778] "Action Point Allowance System" ## [779] "Area Control / Area Influence,Auction/Bidding,Voting" ## [780] "Secret Unit Deployment,Simultaneous Action Selection" ## [781] "Auction/Bidding,Card Drafting,Dice Rolling,Set Collection,Variable Player Powers" ## [782] "Tile Placement" ## [783] "Dice Rolling,Modular Board,Pick-up and Deliver,Point to Point Movement,Role Playing,Variable Player Powers" ## [784] NA ## [785] "Hand Management" ## [786] "Card Drafting,Commodity Speculation" ## [787] "Set Collection" ## [788] "Area Control / Area Influence,Point to Point Movement,Tile Placement" ## [789] "Simultaneous Action Selection" ## [790] "Dice Rolling,Pick-up and Deliver,Route/Network Building,Tile Placement" ## [791] "Press Your Luck,Roll / Spin and Move" ## [792] "Area Enclosure,Grid Movement,Modular Board" ## [793] "Action Point Allowance System,Dice Rolling,Hand Management,Modular Board,Tile Placement,Variable Player Powers" ## [794] "Hand Management,Set Collection,Variable Phase Order" ## [795] "Dice Rolling,Modular Board" ## [796] "Area Control / Area Influence,Area Enclosure,Tile Placement" ## [797] "Auction/Bidding,Set Collection,Trading" ## [798] "Betting/Wagering" ## [799] "Area Enclosure,Hand Management,Point to Point Movement" ## [800] "Modular Board" ## [801] NA ## [802] "Pattern Recognition" ## [803] NA ## [804] "Auction/Bidding,Dice Rolling,Roll / Spin and Move,Set Collection,Trading" ## [805] "Memory" ## [806] "Chit-Pull System,Dice Rolling,Hex-and-Counter,Simulation" ## [807] NA ## [808] "Hand Management,Set Collection" ## [809] "Memory" ## [810] "Action Point Allowance System,Co-operative Play,Dice Rolling,Modular Board,Roll / Spin and Move,Variable Player Powers" ## [811] "Betting/Wagering,Dice Rolling,Roll / Spin and Move,Voting" ## [812] "Campaign / Battle Card Driven,Dice Rolling,Point to Point Movement,Secret Unit Deployment,Simultaneous Action Selection" ## [813] "Area Movement,Campaign / Battle Card Driven,Dice Rolling,Simulation" ## [814] "Dice Rolling,Hand Management" ## [815] "Card Drafting,Dice Rolling,Point to Point Movement,Variable Player Powers" ## [816] "Dice Rolling,Modular Board,Role Playing" ## [817] "Dice Rolling,Roll / Spin and Move" ## [818] "Dice Rolling,Simulation" ## [819] "Dice Rolling,Hand Management,Pick-up and Deliver" ## [820] NA ## [821] "Hand Management,Modular Board,Point to Point Movement,Simultaneous Action Selection" ## [822] "Card Drafting,Hand Management,Pattern Building,Set Collection" ## [823] "Grid Movement" ## [824] NA ## [825] "Action / Movement Programming,Modular Board" ## [826] "Dice Rolling,Hex-and-Counter,Simulation" ## [827] "Action / Movement Programming" ## [828] "Dice Rolling,Variable Player Powers" ## [829] "Campaign / Battle Card Driven,Point to Point Movement" ## [830] "Auction/Bidding,Roll / Spin and Move,Set Collection,Trading" ## [831] "Dice Rolling,Point to Point Movement,Variable Player Powers" ## [832] "Dice Rolling,Hand Management" ## [833] "Betting/Wagering,Simultaneous Action Selection" ## [834] "Hand Management" ## [835] NA ## [836] "Paper-and-Pencil,Partnerships" ## [837] NA ## [838] "Commodity Speculation,Roll / Spin and Move" ## [839] "Dice Rolling,Hex-and-Counter,Simulation" ## [840] "Hand Management,Set Collection" ## [841] NA ## [842] "Variable Player Powers" ## [843] "Card Drafting,Hand Management" ## [844] "Acting" ## [845] "Dice Rolling,Tile Placement,Variable Player Powers" ## [846] NA ## [847] NA ## [848] "Set Collection" ## [849] "Dice Rolling" ## [850] NA ## [851] "Auction/Bidding,Hand Management,Simultaneous Action Selection" ## [852] NA ## [853] "Hand Management" ## [854] "Area Enclosure,Tile Placement" ## [855] "Modular Board" ## [856] "Set Collection" ## [857] "Action Point Allowance System,Area Control / Area Influence,Pick-up and Deliver,Point to Point Movement,Set Collection" ## [858] "Campaign / Battle Card Driven,Modular Board,Pick-up and Deliver,Point to Point Movement,Press Your Luck,Roll / Spin and Move,Tile Placement" ## [859] "Area Enclosure,Auction/Bidding,Hand Management,Tile Placement" ## [860] "Area Control / Area Influence,Point to Point Movement,Tile Placement" ## [861] "Dice Rolling" ## [862] "Action Point Allowance System,Dice Rolling,Point to Point Movement,Roll / Spin and Move" ## [863] "Dice Rolling,Hex-and-Counter,Simulation" ## [864] "Chit-Pull System,Dice Rolling,Hex-and-Counter,Simulation" ## [865] "Card Drafting,Hand Management,Role Playing,Variable Phase Order,Variable Player Powers" ## [866] "Route/Network Building,Stock Holding,Tile Placement" ## [867] "Dice Rolling,Hex-and-Counter,Simulation" ## [868] "Card Drafting,Hand Management,Set Collection" ## [869] NA ## [870] "Dice Rolling" ## [871] "Dice Rolling" ## [872] "Dice Rolling,Role Playing,Variable Player Powers" ## [873] "Hand Management" ## [874] "Area Control / Area Influence,Card Drafting,Hand Management,Set Collection,Take That" ## [875] "Action / Movement Programming,Player Elimination,Simulation,Simultaneous Action Selection" ## [876] "Hand Management,Route/Network Building,Set Collection" ## [877] NA ## [878] "Area Control / Area Influence,Simulation,Variable Player Powers" ## [879] "Auction/Bidding,Hand Management,Press Your Luck" ## [880] "Card Drafting,Set Collection" ## [881] "Hand Management,Partnerships,Route/Network Building,Take That" ## [882] "Set Collection" ## [883] "Dice Rolling" ## [884] "Line Drawing,Paper-and-Pencil" ## [885] "Pattern Building,Trading" ## [886] "Modular Board,Point to Point Movement,Tile Placement" ## [887] "Area Control / Area Influence,Auction/Bidding" ## [888] "Area Movement,Modular Board,Simultaneous Action Selection" ## [889] "Voting" ## [890] "Set Collection" ## [891] "Action Point Allowance System,Modular Board" ## [892] NA ## [893] "Area Control / Area Influence,Point to Point Movement,Route/Network Building,Simultaneous Action Selection,Variable Player Powers" ## [894] "Hand Management" ## [895] "Auction/Bidding,Hand Management,Variable Player Powers" ## [896] "Hand Management" ## [897] NA ## [898] "Action Point Allowance System,Area Control / Area Influence,Modular Board,Tile Placement" ## [899] "Pattern Building,Pattern Recognition" ## [900] "Modular Board" ## [901] "Hand Management" ## [902] NA ## [903] "Action Point Allowance System,Area Control / Area Influence,Area Movement,Campaign / Battle Card Driven,Dice Rolling,Hand Management" ## [904] "Betting/Wagering,Commodity Speculation,Hand Management" ## [905] "Area Control / Area Influence,Area Enclosure,Hand Management,Tile Placement" ## [906] "Crayon Rail System,Pick-up and Deliver,Route/Network Building" ## [907] "Area Control / Area Influence,Area Movement,Auction/Bidding,Dice Rolling" ## [908] "Area Control / Area Influence,Modular Board,Tile Placement" ## [909] "Auction/Bidding,Point to Point Movement,Rock-Paper-Scissors,Simultaneous Action Selection" ## [910] "Area Movement,Pick-up and Deliver" ## [911] "Hand Management,Partnerships,Pattern Building,Tile Placement" ## [912] "Action Point Allowance System,Area Control / Area Influence,Area Enclosure,Hand Management,Modular Board,Route/Network Building,Tile Placement" ## [913] "Hand Management,Point to Point Movement,Simulation" ## [914] "Hand Management,Take That" ## [915] "Take That" ## [916] "Area Movement,Campaign / Battle Card Driven,Card Drafting,Dice Rolling" ## [917] "Partnerships,Variable Player Powers,Voting" ## [918] "Voting" ## [919] "Dice Rolling,Roll / Spin and Move,Variable Player Powers" ## [920] "Dice Rolling,Hex-and-Counter" ## [921] "Area Movement,Area-Impulse,Dice Rolling,Secret Unit Deployment" ## [922] "Dice Rolling,Hex-and-Counter" ## [923] "Auction/Bidding,Memory" ## [924] "Modular Board" ## [925] "Dice Rolling" ## [926] "Hex-and-Counter" ## [927] "Roll / Spin and Move" ## [928] "Hex-and-Counter" ## [929] "Action / Movement Programming,Player Elimination,Simulation,Simultaneous Action Selection" ## [930] "Set Collection,Take That" ## [931] "Grid Movement,Tile Placement,Variable Player Powers" ## [932] "Auction/Bidding,Hand Management,Press Your Luck,Roll / Spin and Move,Set Collection,Stock Holding,Trading" ## [933] "Deck / Pool Building,Hand Management,Pattern Building,Set Collection" ## [934] "Modular Board,Roll / Spin and Move" ## [935] "Roll / Spin and Move,Set Collection" ## [936] "Area Movement,Dice Rolling,Partnerships" ## [937] "Area Movement,Dice Rolling,Partnerships" ## [938] "Dice Rolling,Hex-and-Counter,Simulation" ## [939] "Pattern Recognition" ## [940] "Dice Rolling,Hex-and-Counter" ## [941] "Pattern Recognition" ## [942] "Area-Impulse,Dice Rolling" ## [943] "Dice Rolling,Hex-and-Counter" ## [944] "Area Movement,Modular Board" ## [945] "Pattern Building" ## [946] NA ## [947] "Dice Rolling,Hex-and-Counter,Secret Unit Deployment,Simulation" ## [948] "Pattern Recognition" ## [949] "Hex-and-Counter,Simulation" ## [950] "Hand Management,Set Collection" ## [951] "Role Playing" ## [952] "Area Control / Area Influence,Area Movement,Campaign / Battle Card Driven,Dice Rolling" ## [953] NA ## [954] "Dice Rolling,Modular Board,Variable Player Powers" ## [955] "Hand Management,Variable Player Powers" ## [956] "Action Point Allowance System,Hand Management" ## [957] "Rock-Paper-Scissors,Secret Unit Deployment" ## [958] "Hand Management,Trick-taking" ## [959] "Area Movement,Hand Management,Simulation" ## [960] "Co-operative Play,Dice Rolling,Modular Board,Partnerships,Player Elimination,Role Playing,Storytelling,Variable Player Powers" ## [961] NA ## [962] "Paper-and-Pencil" ## [963] "Pattern Building,Point to Point Movement" ## [964] "Hex-and-Counter" ## [965] "Chit-Pull System,Hex-and-Counter" ## [966] "Area Control / Area Influence,Campaign / Battle Card Driven,Dice Rolling,Grid Movement,Hand Management,Modular Board,Simulation" ## [967] "Dice Rolling,Modular Board,Partnerships,Variable Player Powers" ## [968] "Dice Rolling,Hex-and-Counter" ## [969] "Dice Rolling,Pick-up and Deliver,Point to Point Movement" ## [970] "Hand Management" ## [971] "Hand Management,Modular Board,Pattern Building,Pattern Recognition,Tile Placement" ## [972] "Area Movement,Dice Rolling,Secret Unit Deployment,Simulation" ## [973] "Hex-and-Counter" ## [974] "Dice Rolling,Press Your Luck,Stock Holding" ## [975] "Auction/Bidding,Roll / Spin and Move,Set Collection,Trading" ## [976] "Dice Rolling,Hex-and-Counter,Simulation" ## [977] "Hand Management,Simultaneous Action Selection" ## [978] "Action / Movement Programming,Area Control / Area Influence,Hand Management,Simultaneous Action Selection" ## [979] NA ## [980] NA ## [981] "Dice Rolling,Player Elimination" ## [982] "Area Movement,Variable Player Powers" ## [983] "Area Movement,Campaign / Battle Card Driven,Dice Rolling,Secret Unit Deployment" ## [984] "Press Your Luck,Set Collection" ## [985] "Memory,Set Collection" ## [986] "Memory" ## [987] "Grid Movement" ## [988] "Variable Player Powers" ## [989] "Auction/Bidding" ## [990] "Area Control / Area Influence,Hand Management,Variable Player Powers" ## [991] NA ## [992] "Player Elimination,Roll / Spin and Move" ## [993] "Memory,Paper-and-Pencil" ## [994] "Memory,Simultaneous Action Selection,Variable Player Powers" ## [995] "Partnerships,Voting" ## [996] "Commodity Speculation,Hex-and-Counter,Pick-up and Deliver,Trading,Variable Player Powers" ## [997] "Hex-and-Counter" ## [998] "Area Control / Area Influence,Pattern Building,Tile Placement" ## [999] "Auction/Bidding,Dice Rolling" ## [1000] "Betting/Wagering" ## [ reached getOption("max.print") -- omitted 6552 entries ] ``` --- .middler[<img src="images/stringr.png" alt="" height="350"/>] --- layout: false class: inverse .sectionhead[String Lengths] --- # <TT>str_length()</TT>: number of characters ```r str_length("a") ``` ``` ## [1] 1 ``` ```r str_length("abc") ``` ``` ## [1] 3 ``` ```r str_length(c("a", "ab", "abc")) ``` ``` ## [1] 1 2 3 ``` --- # <TT>str_trim()</TT>: trim whitespace on ends ```r str_trim("cats and dogs") ``` ``` ## [1] "cats and dogs" ``` ```r str_trim(" cats and dogs") ``` ``` ## [1] "cats and dogs" ``` ```r str_trim("cats and dogs ") ``` ``` ## [1] "cats and dogs" ``` ```r str_trim(" cats and dogs ") ``` ``` ## [1] "cats and dogs" ``` ```r str_trim(c("cats", " dogs", "cows ", " chickens ")) ``` ``` ## [1] "cats" "dogs" "cows" "chickens" ``` --- # Today's data set ```r board_games <- board_games %>% mutate(name_length = str_length(name)) ggplot(board_games, aes(x = name_length, y = users_rated)) + geom_point() + theme_bw() + labs(x = "Length of Name", y = "Number of Ratings") ``` <!-- --> --- class: inverse .sectionhead[Subsetting Strings] --- # <TT>str_sub()</TT>: substring by indices * Given one positive value: starting index * Given one negative value: starting index from end * Given two values: starting and ending index (can be positive or negative) ```r strings <- c("strawberry", "banana", "blueberry", "apple", "blackberry", "lemon") str_sub(strings, 3) ``` ``` ## [1] "rawberry" "nana" "ueberry" "ple" "ackberry" "mon" ``` ```r str_sub(strings, 1) ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_sub(strings, -2) ``` ``` ## [1] "ry" "na" "ry" "le" "ry" "on" ``` ```r str_sub(strings, -5) ``` ``` ## [1] "berry" "anana" "berry" "apple" "berry" "lemon" ``` --- # <TT>str_sub()</TT>: substring by indices * Given one positive value: starting index * Given one negative value: starting index from end * Given two values: starting and ending index (can be positive or negative) ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_sub(strings, 1, 3) ``` ``` ## [1] "str" "ban" "blu" "app" "bla" "lem" ``` ```r str_sub(strings, 2, 6) ``` ``` ## [1] "trawb" "anana" "luebe" "pple" "lackb" "emon" ``` ```r str_sub(strings, 3, -4) ``` ``` ## [1] "rawbe" "n" "uebe" "" "ackbe" "" ``` --- # <TT>str_subset()</TT>: subset by pattern ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_subset(strings, "a") ``` ``` ## [1] "strawberry" "banana" "apple" "blackberry" ``` ```r str_subset(strings, "berry") ``` ``` ## [1] "strawberry" "blueberry" "blackberry" ``` ```r str_subset(strings, "apple") ``` ``` ## [1] "apple" ``` ```r str_subset(strings, "appel") ``` ``` ## character(0) ``` --- # <TT>str_extract()</TT>: extract by pattern ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_extract(strings, "a") ``` ``` ## [1] "a" "a" NA "a" "a" NA ``` ```r str_extract(strings, "berry") ``` ``` ## [1] "berry" NA "berry" NA "berry" NA ``` ```r str_extract(strings, "apple") ``` ``` ## [1] NA NA NA "apple" NA NA ``` ```r str_extract(strings, "[aeiou]") ``` ``` ## [1] "a" "a" "u" "a" "a" "e" ``` --- class: inverse .sectionhead[Matching] --- # <TT>str_detect()</TT>: Booleans for matching ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_detect(strings, "a") ``` ``` ## [1] TRUE TRUE FALSE TRUE TRUE FALSE ``` ```r str_detect(strings, "berry") ``` ``` ## [1] TRUE FALSE TRUE FALSE TRUE FALSE ``` ```r str_detect(strings, "[aeiou]") ``` ``` ## [1] TRUE TRUE TRUE TRUE TRUE TRUE ``` --- # <TT>str_which()</TT>: index for matching Note: this returns the index of the matching string, not the index of the matching character within the string! ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_which(strings, "a") ``` ``` ## [1] 1 2 4 5 ``` ```r str_which(strings, "berry") ``` ``` ## [1] 1 3 5 ``` ```r str_which(strings, "[aeiou]") ``` ``` ## [1] 1 2 3 4 5 6 ``` --- # <TT>str_locate()</TT>: position for matching Note: this returns the position index of the *first* matching string! ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_locate(strings, "a") ``` ``` ## start end ## [1,] 4 4 ## [2,] 2 2 ## [3,] NA NA ## [4,] 1 1 ## [5,] 3 3 ## [6,] NA NA ``` --- # <TT>str_locate()</TT>: position for matching Note: this returns the position index of the *first* matching string! ```r str_locate(strings, "berry") ``` ``` ## start end ## [1,] 6 10 ## [2,] NA NA ## [3,] 5 9 ## [4,] NA NA ## [5,] 6 10 ## [6,] NA NA ``` ```r str_locate(strings, "[aeiou]") ``` ``` ## start end ## [1,] 4 4 ## [2,] 2 2 ## [3,] 3 3 ## [4,] 1 1 ## [5,] 3 3 ## [6,] 2 2 ``` --- # <TT>str_count()</TT>: count matches ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_count(strings, "a") ``` ``` ## [1] 1 3 0 1 1 0 ``` ```r str_count(strings, "berry") ``` ``` ## [1] 1 0 1 0 1 0 ``` ```r str_count(strings, "[aeiou]") ``` ``` ## [1] 2 3 3 2 2 2 ``` --- # Today's data set ```r monopoly_games <- board_games %>% filter(str_detect(name, "Monopoly")) ggplot(monopoly_games, aes(y = average_rating, x = users_rated, label = name)) + geom_point() + geom_text(check_overlap = TRUE, hjust = 0, nudge_x = 100, size = 4) + labs(y = "Average rating", x = "Number of ratings") + lims(x = c(0, 8000)) + theme_bw() ``` -- <!-- --> --- class: inverse .sectionhead[Joining and Splitting] --- # <TT>str_c()</TT>: join multiple strings Use `sep = ` to set the separating string ```r str_c(c("a", "b", "c"), c("1", "2", "3")) ``` ``` ## [1] "a1" "b2" "c3" ``` ```r str_c(c("a", "b", "c"), c("1", "2", "3"), sep = "_") ``` ``` ## [1] "a_1" "b_2" "c_3" ``` ```r str_c(c("a", "b", "c"), c("1", "2", "3"), sep = "!@#$") ``` ``` ## [1] "a!@#$1" "b!@#$2" "c!@#$3" ``` --- # <TT>str_c()</TT>: collapse a string vector Use `collapse = ` to set the combining string ```r str_c(c("a", "b", "c"), collapse = "") ``` ``` ## [1] "abc" ``` ```r str_c(c("a", "b", "c"), collapse = "_") ``` ``` ## [1] "a_b_c" ``` ```r str_c(c("a", "b", "c"), c("1", "2", "3"), collapse = "") ``` ``` ## [1] "a1b2c3" ``` --- # <TT>str_split_fixed()</TT>: split string `str_split_fixed(string, pattern, n)`, where `n` is the maximum number of pieces after splitting. Use `Inf` for all possible splits. ```r str_split_fixed(c("a", "a b", "a b c"), " ", 2) ``` ``` ## [,1] [,2] ## [1,] "a" "" ## [2,] "a" "b" ## [3,] "a" "b c" ``` ```r str_split_fixed(c("a", "a b", "a b c"), " ", Inf) ``` ``` ## [,1] [,2] [,3] ## [1,] "a" "" "" ## [2,] "a" "b" "" ## [3,] "a" "b" "c" ``` --- # <TT>str_split_fixed()</TT>: split string `str_split_fixed(string, pattern, n)`, where `n` is the maximum number of pieces after splitting. ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_split_fixed(strings, "a", Inf) ``` ``` ## [,1] [,2] [,3] [,4] ## [1,] "str" "wberry" "" "" ## [2,] "b" "n" "n" "" ## [3,] "blueberry" "" "" "" ## [4,] "" "pple" "" "" ## [5,] "bl" "ckberry" "" "" ## [6,] "lemon" "" "" "" ``` --- # What is the most common mechanic? ```r head(board_games$mechanic) ``` ``` ## [1] "Hand Management" ## [2] "Auction/Bidding,Card Drafting,Hand Management,Route/Network Building,Set Collection" ## [3] "Card Drafting,Set Collection,Simultaneous Action Selection,Variable Phase Order,Variable Player Powers" ## [4] "Area Control / Area Influence,Dice Rolling,Hand Management,Modular Board,Partnerships" ## [5] "Hex-and-Counter" ## [6] "Area Control / Area Influence,Card Drafting,Hand Management,Route/Network Building" ``` -- ```r mechanics_mat <- str_split_fixed(board_games$mechanic, ',', n = Inf) dim(mechanics_mat) ``` ``` ## [1] 7552 18 ``` --- # What is the most common mechanic? ```r all_mechanics <- unique(as.vector(mechanics_mat)) all_mechanics <- all_mechanics[all_mechanics != ""] all_mechanics ``` ``` ## [1] "Hand Management" "Auction/Bidding" "Card Drafting" ## [4] "Area Control / Area Influence" "Hex-and-Counter" "Set Collection" ## [7] "Pattern Building" "Voting" "Dice Rolling" ## [10] "Area Movement" "Trick-taking" "Tile Placement" ## [13] "Area-Impulse" "Action / Movement Programming" "Action Point Allowance System" ## [16] "Take That" "Simultaneous Action Selection" "Stock Holding" ## [19] "Betting/Wagering" "Campaign / Battle Card Driven" "Variable Player Powers" ## [22] "Partnerships" "Co-operative Play" "Modular Board" ## [25] "Memory" "Point to Point Movement" "Roll / Spin and Move" ## [28] "Route/Network Building" "Grid Movement" "Role Playing" ## [31] "Pick-up and Deliver" "Area Enclosure" "Rock-Paper-Scissors" ## [34] "Paper-and-Pencil" "Pattern Recognition" "Storytelling" ## [37] "Chit-Pull System" "Variable Phase Order" "Commodity Speculation" ## [40] "Trading" "Line Drawing" "Press Your Luck" ## [43] "Acting" "Simulation" "Crayon Rail System" ## [46] "Secret Unit Deployment" "Deck / Pool Building" "Player Elimination" ## [49] "Time Track" "Worker Placement" "Singing" ``` --- # What is the most common mechanic? ```r for (mech in all_mechanics) { board_games[[mech]] <- str_detect(board_games$mechanic, mech) mech_prop <- round(mean(board_games[[mech]], na.rm = T), 3) print(str_c("Proportion of games with ", mech, " : ", mech_prop)) } ``` ``` ## [1] "Proportion of games with Hand Management : 0.281" ## [1] "Proportion of games with Auction/Bidding : 0.076" ## [1] "Proportion of games with Card Drafting : 0.114" ## [1] "Proportion of games with Area Control / Area Influence : 0.104" ## [1] "Proportion of games with Hex-and-Counter : 0.062" ## [1] "Proportion of games with Set Collection : 0.161" ## [1] "Proportion of games with Pattern Building : 0.038" ## [1] "Proportion of games with Voting : 0.025" ## [1] "Proportion of games with Dice Rolling : 0.268" ## [1] "Proportion of games with Area Movement : 0.065" ## [1] "Proportion of games with Trick-taking : 0.015" ## [1] "Proportion of games with Tile Placement : 0.107" ## [1] "Proportion of games with Area-Impulse : 0.005" ## [1] "Proportion of games with Action / Movement Programming : 0.02" ## [1] "Proportion of games with Action Point Allowance System : 0.07" ## [1] "Proportion of games with Take That : 0.035" ## [1] "Proportion of games with Simultaneous Action Selection : 0.068" ## [1] "Proportion of games with Stock Holding : 0.018" ## [1] "Proportion of games with Betting/Wagering : 0.019" ## [1] "Proportion of games with Campaign / Battle Card Driven : 0.036" ## [1] "Proportion of games with Variable Player Powers : 0.149" ## [1] "Proportion of games with Partnerships : 0.053" ## [1] "Proportion of games with Co-operative Play : 0.06" ## [1] "Proportion of games with Modular Board : 0.103" ## [1] "Proportion of games with Memory : 0.047" ## [1] "Proportion of games with Point to Point Movement : 0.052" ## [1] "Proportion of games with Roll / Spin and Move : 0.052" ## [1] "Proportion of games with Route/Network Building : 0.037" ## [1] "Proportion of games with Grid Movement : 0.046" ## [1] "Proportion of games with Role Playing : 0.027" ## [1] "Proportion of games with Pick-up and Deliver : 0.036" ## [1] "Proportion of games with Area Enclosure : 0.014" ## [1] "Proportion of games with Rock-Paper-Scissors : 0.009" ## [1] "Proportion of games with Paper-and-Pencil : 0.01" ## [1] "Proportion of games with Pattern Recognition : 0.024" ## [1] "Proportion of games with Storytelling : 0.019" ## [1] "Proportion of games with Chit-Pull System : 0.013" ## [1] "Proportion of games with Variable Phase Order : 0.025" ## [1] "Proportion of games with Commodity Speculation : 0.015" ## [1] "Proportion of games with Trading : 0.038" ## [1] "Proportion of games with Line Drawing : 0.005" ## [1] "Proportion of games with Press Your Luck : 0.042" ## [1] "Proportion of games with Acting : 0.013" ## [1] "Proportion of games with Simulation : 0.048" ## [1] "Proportion of games with Crayon Rail System : 0.001" ## [1] "Proportion of games with Secret Unit Deployment : 0.029" ## [1] "Proportion of games with Deck / Pool Building : 0.046" ## [1] "Proportion of games with Player Elimination : 0.03" ## [1] "Proportion of games with Time Track : 0.007" ## [1] "Proportion of games with Worker Placement : 0.049" ## [1] "Proportion of games with Singing : 0.003" ``` --- # What is the most common mechanic? ```r colnames(board_games) ``` ``` ## [1] "game_id" "description" "image" ## [4] "max_players" "max_playtime" "min_age" ## [7] "min_players" "min_playtime" "name" ## [10] "playing_time" "thumbnail" "year_published" ## [13] "artist" "category" "compilation" ## [16] "designer" "expansion" "family" ## [19] "mechanic" "publisher" "average_rating" ## [22] "users_rated" "name_length" "Hand Management" ## [25] "Auction/Bidding" "Card Drafting" "Area Control / Area Influence" ## [28] "Hex-and-Counter" "Set Collection" "Pattern Building" ## [31] "Voting" "Dice Rolling" "Area Movement" ## [34] "Trick-taking" "Tile Placement" "Area-Impulse" ## [37] "Action / Movement Programming" "Action Point Allowance System" "Take That" ## [40] "Simultaneous Action Selection" "Stock Holding" "Betting/Wagering" ## [43] "Campaign / Battle Card Driven" "Variable Player Powers" "Partnerships" ## [46] "Co-operative Play" "Modular Board" "Memory" ## [49] "Point to Point Movement" "Roll / Spin and Move" "Route/Network Building" ## [52] "Grid Movement" "Role Playing" "Pick-up and Deliver" ## [55] "Area Enclosure" "Rock-Paper-Scissors" "Paper-and-Pencil" ## [58] "Pattern Recognition" "Storytelling" "Chit-Pull System" ## [61] "Variable Phase Order" "Commodity Speculation" "Trading" ## [64] "Line Drawing" "Press Your Luck" "Acting" ## [67] "Simulation" "Crayon Rail System" "Secret Unit Deployment" ## [70] "Deck / Pool Building" "Player Elimination" "Time Track" ## [73] "Worker Placement" "Singing" ``` --- # What is the most common mechanic? ```r colMeans(board_games[all_mechanics], na.rm = T) %>% sort(decreasing = T) ``` ``` ## Hand Management Dice Rolling Set Collection ## 0.280711825 0.267508611 0.160878301 ## Variable Player Powers Card Drafting Tile Placement ## 0.149397245 0.113518944 0.106773823 ## Area Control / Area Influence Modular Board Auction/Bidding ## 0.103616533 0.103473020 0.075631458 ## Action Point Allowance System Simultaneous Action Selection Area Movement ## 0.069890930 0.067738232 0.065011481 ## Hex-and-Counter Co-operative Play Partnerships ## 0.061854191 0.060132032 0.053243398 ## Roll / Spin and Move Point to Point Movement Worker Placement ## 0.051951780 0.051664753 0.049081515 ## Simulation Memory Grid Movement ## 0.047502870 0.047359357 0.046354765 ## Deck / Pool Building Press Your Luck Trading ## 0.046211251 0.042192882 0.037743972 ## Pattern Building Route/Network Building Pick-up and Deliver ## 0.037600459 0.037313433 0.036452354 ## Campaign / Battle Card Driven Take That Player Elimination ## 0.035734788 0.034586682 0.029994259 ## Secret Unit Deployment Role Playing Voting ## 0.029276693 0.026549943 0.025258324 ## Variable Phase Order Pattern Recognition Action / Movement Programming ## 0.024540758 0.024110218 0.019948335 ## Betting/Wagering Storytelling Stock Holding ## 0.018656716 0.018656716 0.017939150 ## Commodity Speculation Trick-taking Area Enclosure ## 0.015212400 0.015068886 0.013920781 ## Chit-Pull System Acting Paper-and-Pencil ## 0.013203215 0.013059701 0.010476464 ## Rock-Paper-Scissors Time Track Line Drawing ## 0.008897819 0.007175660 0.005309989 ## Area-Impulse Singing Crayon Rail System ## 0.005166475 0.002583238 0.001004592 ``` --- class: inverse .sectionhead[Mutate Strings] --- # <TT>str_replace()</TT>: replace first match `str_replace(string, pattern, replacement)` ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_replace(strings, "a", "A") ``` ``` ## [1] "strAwberry" "bAnana" "blueberry" "Apple" "blAckberry" "lemon" ``` ```r str_replace(strings, "berry", "123") ``` ``` ## [1] "straw123" "banana" "blue123" "apple" "black123" "lemon" ``` ```r str_replace(strings, "[aeiou]", "y") ``` ``` ## [1] "strywberry" "bynana" "blyeberry" "ypple" "blyckberry" "lymon" ``` --- # <TT>str_replace_all()</TT>: replace matches `str_replace_all(string, pattern, replacement)` ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_replace_all(strings, "a", "A") ``` ``` ## [1] "strAwberry" "bAnAnA" "blueberry" "Apple" "blAckberry" "lemon" ``` ```r str_replace_all(strings, "berry", "123") ``` ``` ## [1] "straw123" "banana" "blue123" "apple" "black123" "lemon" ``` ```r str_replace_all(strings, "[aeiou]", "y") ``` ``` ## [1] "strywbyrry" "bynyny" "blyybyrry" "ypply" "blyckbyrry" "lymyn" ``` --- # Changing case * `str_to_lower()` make lowercase ```r str_to_lower(c("A STRING", "A sTrInG", "A String", "a string", "A STRING!!1")) ``` ``` ## [1] "a string" "a string" "a string" "a string" "a string!!1" ``` * `str_to_upper()` make uppercase ```r str_to_upper(c("A STRING", "A sTrInG", "A String", "a string", "A STRING!!1")) ``` ``` ## [1] "A STRING" "A STRING" "A STRING" "A STRING" "A STRING!!1" ``` * `str_to_title()` make title case ```r str_to_title(c("A STRING", "A sTrInG", "A String", "a string", "A STRING!!1")) ``` ``` ## [1] "A String" "A String" "A String" "A String" "A String!!1" ``` --- class: inverse .sectionhead[Order Strings] --- # <TT>str_order()</TT>: get sorting vector Options: `decreasing`, `na_last`, `numeric` ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_order(strings) ``` ``` ## [1] 4 2 5 3 6 1 ``` ```r strings[str_order(strings)] ``` ``` ## [1] "apple" "banana" "blackberry" "blueberry" "lemon" "strawberry" ``` ```r strings[str_order(strings, decreasing = TRUE)] ``` ``` ## [1] "strawberry" "lemon" "blueberry" "blackberry" "banana" "apple" ``` --- # <TT>str_sort()</TT>: sort string vector Options: `decreasing`, `na_last`, `numeric` ```r strings ``` ``` ## [1] "strawberry" "banana" "blueberry" "apple" "blackberry" "lemon" ``` ```r str_sort(strings) ``` ``` ## [1] "apple" "banana" "blackberry" "blueberry" "lemon" "strawberry" ``` ```r str_sort(strings, decreasing = TRUE) ``` ``` ## [1] "strawberry" "lemon" "blueberry" "blackberry" "banana" "apple" ``` --- # <TT>str_sort()</TT>: sort string vector Options: `decreasing`, `na_last`, `numeric` ```r nums <- c("1", "2", "3", NA, "11", "120", "010") str_sort(nums) ``` ``` ## [1] "010" "1" "11" "120" "2" "3" NA ``` ```r str_sort(nums, na_last = FALSE) ``` ``` ## [1] NA "010" "1" "11" "120" "2" "3" ``` ```r str_sort(nums, numeric = TRUE) ``` ``` ## [1] "1" "2" "3" "010" "11" "120" NA ``` --- # <TT>stringr</TT> cheatsheet * Manage lengths: `str_length()`, `str_trim()` * Subsetting: `str_sub()`, `str_subset()`, `str_extract()` * Matching: `str_detect()`, `str_which()`, `str_locate()`, `str_count()` * Joining and Splitting: `str_c()`, `str_split_fixed()` * Mutate: `str_replace()`, `str_replace_all()`, `str_to_lower()`, `str_to_upper()`, `str_to_title()` .pushdown[.center[[And more! Click me for a cheat sheet!](https://rstudio.com/resources/cheatsheets/) <img src="stringr.png" alt="" height="150"/>]] --- class: inverse .sectionhead[Part 2. Factors] --- .middler[<img src="images/forcats.png" alt="" height="350"/>] --- # Factors Recall... **factors** are categorical data that use integer representation. This can be efficient to store character vectors, because each string is only entered once. Because of this, creating data frames (but not tibbles!) in R often default to set strings as factors. --- # Movies data ```r movies <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2018/2018-10-23/movie_profit.csv") colnames(movies) ``` ``` ## [1] "X1" "release_date" "movie" "production_budget" "domestic_gross" ## [6] "worldwide_gross" "distributor" "mpaa_rating" "genre" ``` --- # Movies data ```r genre_char <- movies$genre genre_fct <- as.factor(movies$genre) head(genre_char) ``` ``` ## [1] "Comedy" "Action" "Adventure" "Action" "Action" "Action" ``` ```r head(genre_fct) ``` ``` ## [1] Comedy Action Adventure Action Action Action ## Levels: Action Adventure Comedy Drama Horror ``` --- # Movies data ```r object.size(genre_char) ``` ``` ## 27544 bytes ``` ```r object.size(genre_fct) ``` ``` ## 14376 bytes ``` --- # Movies data ```r movies <- movies %>% mutate(genre = as.factor(genre)) %>% mutate(return = worldwide_gross / production_budget) genre_medians <- movies %>% group_by(genre) %>% summarize(median_budget = median(production_budget), median_domestic = median(domestic_gross), median_ww = median(worldwide_gross), median_return = median(return)) %>% ungroup() ``` --- # Movies data ```r ggplot(genre_medians, aes(x = genre, y = median_return)) + geom_bar(stat="identity") + theme(text = element_text(size = 20)) ``` <!-- --> --- # <TT>factor()</TT>: create a factor ```r (f1 <- factor(c("a", "b", "c", "a"), levels = c("a", "b", "c"))) ``` ``` ## [1] a b c a ## Levels: a b c ``` ```r factor(c("a", "b", "c", "a"), levels = c("a", "b", "d")) ``` ``` ## [1] a b <NA> a ## Levels: a b d ``` ```r (f2 <- factor(c("a", "b", "c", "a"), levels = c("a", "b", "c", "d"))) ``` ``` ## [1] a b c a ## Levels: a b c d ``` --- # <TT>factor()</TT>: create a factor ```r f1[5] <- "d" ``` ``` ## Warning in `[<-.factor`(`*tmp*`, 5, value = "d"): invalid factor level, NA generated ``` ```r f1 ``` ``` ## [1] a b c a <NA> ## Levels: a b c ``` ```r f2[5] <- "d" f2 ``` ``` ## [1] a b c a d ## Levels: a b c d ``` --- # <TT>fct_count()</TT>: count levels ```r f1 ``` ``` ## [1] a b c a <NA> ## Levels: a b c ``` ```r fct_count(f1) ``` ``` ## # A tibble: 4 x 2 ## f n ## <fct> <int> ## 1 a 2 ## 2 b 1 ## 3 c 1 ## 4 <NA> 1 ``` --- # <TT>fct_count()</TT>: count levels ```r f2 ``` ``` ## [1] a b c a d ## Levels: a b c d ``` ```r fct_count(f2) ``` ``` ## # A tibble: 4 x 2 ## f n ## <fct> <int> ## 1 a 2 ## 2 b 1 ## 3 c 1 ## 4 d 1 ``` --- # <TT>fct_unique()</TT>: unique levels ```r f1 ``` ``` ## [1] a b c a <NA> ## Levels: a b c ``` ```r fct_unique(f1) ``` ``` ## [1] a b c ## Levels: a b c ``` ```r f2 ``` ``` ## [1] a b c a d ## Levels: a b c d ``` ```r fct_unique(f2) ``` ``` ## [1] a b c d ## Levels: a b c d ``` --- # <TT>fct_c()</TT>: combine factors This can be useful if all the levels were not included initially! ```r f_small_1 <- factor(c("b", "a"), levels = c("a", "b")) f_small_2 <- factor(c("a", "c"), levels = c("a", "c")) fct_c(f_small_1, f_small_2) ``` ``` ## [1] b a a c ## Levels: a b c ``` Compare to ```r c(f_small_1, f_small_2) ``` ``` ## [1] 2 1 1 2 ``` --- # <TT>fct_relevel()</TT>: manually relevel ```r f2 ``` ``` ## [1] a b c a d ## Levels: a b c d ``` ```r fct_relevel(f2, c("b", "d", "a", "c")) ``` ``` ## [1] a b c a d ## Levels: b d a c ``` ```r fct_relevel(f2, c("b", "d", "a")) ``` ``` ## [1] a b c a d ## Levels: b d a c ``` --- # <TT>fct_relevel()</TT>: manually relevel ```r f2 ``` ``` ## [1] a b c a d ## Levels: a b c d ``` ```r as.numeric(f2) ``` ``` ## [1] 1 2 3 1 4 ``` ```r fct_relevel(f2, c("b", "d", "a", "c")) %>% as.numeric ``` ``` ## [1] 3 1 4 3 2 ``` --- # <TT>fct_drop()</TT>: drop unused levels By default, drops all unused levels. Alternatively, supply levels to drop. ```r f3 <- factor(c("a", "b", "b", "a"), levels = c("a", "b", "c", "d")) fct_drop(f3) ``` ``` ## [1] a b b a ## Levels: a b ``` ```r fct_drop(f3, only = "d") ``` ``` ## [1] a b b a ## Levels: a b c ``` --- # <TT>fct_expand()</TT>: add levels By default, drops all unused levels. Alternatively, supply levels to drop. ```r f3 <- factor(c("a", "b", "b", "a"), levels = c("a", "b")) fct_expand(f3, "c") ``` ``` ## [1] a b b a ## Levels: a b c ``` ```r fct_expand(f3, "c", "d") ``` ``` ## [1] a b b a ## Levels: a b c d ``` --- # <TT>fct_recode()</TT>: recode levels ```r f2 ``` ``` ## [1] a b c a d ## Levels: a b c d ``` ```r fct_recode(f2, x = "a") ``` ``` ## [1] x b c x d ## Levels: x b c d ``` ```r fct_recode(f2, x = "a", y = "b", z = "c", w = "d") ``` ``` ## [1] x y z x w ## Levels: x y z w ``` --- # <TT>fct_collapse()</TT>: collapse levels ```r f2 ``` ``` ## [1] a b c a d ## Levels: a b c d ``` ```r fct_collapse(f2, x = c("a", "b")) ``` ``` ## [1] x x c x d ## Levels: x c d ``` --- # <TT>fct_other()</TT>: replace w/ "Other" ```r f2 ``` ``` ## [1] a b c a d ## Levels: a b c d ``` ```r fct_other(f2, keep = "a") ``` ``` ## [1] a Other Other a Other ## Levels: a Other ``` ```r fct_other(f2, keep = c("a", "b")) ``` ``` ## [1] a b Other a Other ## Levels: a b Other ``` --- # Movies data ```r movies <- movies %>% mutate(genre = fct_collapse(genre, AA = c("Action", "Adventure"))) %>% mutate(genre = fct_recode(genre, Scary = "Horror")) genre_medians <- movies %>% group_by(genre) %>% summarize(median_budget = median(production_budget), median_domestic = median(domestic_gross), median_ww = median(worldwide_gross), median_return = median(return)) %>% ungroup() ``` --- # Movies data ```r ggplot(genre_medians, aes(x = genre, y = median_return)) + geom_bar(stat="identity") + theme(text = element_text(size=20)) ``` <!-- --> --- # <TT>forcats</TT> cheatsheet * Create a factor: `factor(..., levels = ...)` * Count levels: `fct_count()` * Unique levels: `fct_unique()` * Combine factor vectors: `fct_c()` * Relevel: `fct_relevel()` * Drop levels: `fct_drop()` * Add levels: `fct_expand()` * Recode levels: `fct_recode()` * Collapse levels: `fct_collapse()` * "Other" level: `fct_other()` .center[[And more! Click me for a cheat sheet!](https://rstudio.com/resources/cheatsheets/) <img src="forcats.png" alt="" height="150"/>] --- class: inverse .sectionhead[Part 3: Dates and Times] --- .middler[<img src="lubridate.png" alt="" height="350"/>] --- ```r library(lubridate) ``` --- ```r head(movies$release_date) ``` ``` ## [1] "6/22/2007" "7/28/1995" "5/12/2017" "12/25/2013" "6/22/2018" "8/1/2014" ``` --- layout: true # Parsing Date-times --- **Dates** and **date-times** are special classes of objects in R. `lubridate` does a fantastic job of taking a variety of input and converting them into standardized format using for dates: * **y** for year * **m** for month * **d** for day * **q** for quarter and for times: * **h** for hour * **m** for minute * **s** for second You can combine these into more functions and inputs than we are able to show, but we'll go through several examples. --- Ordering can be changed arbitrarily. ```r mdy("01-29-2020") ``` ``` ## [1] "2020-01-29" ``` ```r dmy("29-01-2020") ``` ``` ## [1] "2020-01-29" ``` ```r ymd("2020-01-29") ``` ``` ## [1] "2020-01-29" ``` ```r ydm("2020-29-01") ``` ``` ## [1] "2020-01-29" ``` --- It accepts a variety of input formats. ```r mdy("Jan 29, 2020") ``` ``` ## [1] "2020-01-29" ``` ```r dmy("29th of January, 2020") ``` ``` ## [1] "2020-01-29" ``` ```r mdy("01/29/20") ``` ``` ## [1] "2020-01-29" ``` ```r ymd("20200129") ``` ``` ## [1] "2020-01-29" ``` ```r ymd("2020-01-29") ``` ``` ## [1] "2020-01-29" ``` --- ```r head(movies$release_date) ``` ``` ## [1] "6/22/2007" "7/28/1995" "5/12/2017" "12/25/2013" "6/22/2018" "8/1/2014" ``` -- ```r head(mdy(movies$release_date)) ``` ``` ## [1] "2007-06-22" "1995-07-28" "2017-05-12" "2013-12-25" "2018-06-22" "2014-08-01" ``` --- We can add times, and even quarters. ```r yq("2020: Q1") ``` ``` ## [1] "2020-01-01" ``` ```r yq("2020 Quarter 1") ``` ``` ## [1] "2020-01-01" ``` ```r dmy_h("29 Jan 2020 at 2pm") ``` ``` ## [1] "2020-01-29 14:00:00 UTC" ``` ```r mdy_hms("Jan 29th 2020, 4:10:43") ``` ``` ## [1] "2020-01-29 04:10:43 UTC" ``` --- layout: false layout: true # Extracting Date-time Components --- When we have an object in date-time form, we can easily extract information. ```r (x <- ymd_hms("2020-01-29, 3:29:59 pm", tz = "US/Pacific")) ``` ``` ## [1] "2020-01-29 15:29:59 PST" ``` ```r date(x) ``` ``` ## [1] "2020-01-29" ``` ```r year(x) ``` ``` ## [1] 2020 ``` ```r month(x) ``` ``` ## [1] 1 ``` ```r day(x) ``` ``` ## [1] 29 ``` --- ```r head(mdy(movies$release_date)) ``` ``` ## [1] "2007-06-22" "1995-07-28" "2017-05-12" "2013-12-25" "2018-06-22" "2014-08-01" ``` -- ```r head(year(mdy(movies$release_date))) ``` ``` ## [1] 2007 1995 2017 2013 2018 2014 ``` --- ```r hour(x) ``` ``` ## [1] 15 ``` ```r minute(x) ``` ``` ## [1] 29 ``` ```r second(x) ``` ``` ## [1] 59 ``` ```r tz(x) ``` ``` ## [1] "US/Pacific" ``` --- ```r wday(x) # day of week ``` ``` ## [1] 4 ``` ```r wday(x, label = TRUE) ``` ``` ## [1] Wed ## Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat ``` ```r week(x) # week of year ``` ``` ## [1] 5 ``` ```r quarter(x) # quarter of year ``` ``` ## [1] 1 ``` --- ```r dst(x) # is it Daylight Savings time? ``` ``` ## [1] FALSE ``` ```r leap_year(x) # is it a leap year? ``` ``` ## [1] TRUE ``` ```r am(x) ``` ``` ## [1] FALSE ``` ```r pm(x) ``` ``` ## [1] TRUE ``` --- We can also edit date-time objects. ```r x ``` ``` ## [1] "2020-01-29 15:29:59 PST" ``` ```r hour(x) <- 13 year(x) <- 2021 x ``` ``` ## [1] "2021-01-29 13:29:59 PST" ``` --- layout: false # Tell R when you have date-times! When working with date-time data, it is important that you tell R you are working with date-times using `lubridate`! If you do not, you may get an error that looks like this: ```r x <- "01/29/2020" day(x) ``` ``` ## Error in as.POSIXlt.character(x, tz = tz(x)): character string is not in a standard unambiguous format ``` ```r y <- mdy(x) day(y) ``` ``` ## [1] 29 ``` --- # <TT>lubridate</TT> cheatsheet * Dates: `y` year, `m` month, `d` day, `q` quarter * Times: `h` hour, `m` minute, `s` second * Extracting components: `date()`, `year()`, `month()`, `day()`, `hour()`, `minute()`, `second()` You can do much more that we didn't cover here, such as intervals, arithmetic, durations, rounding, and periods! .center[[Click me for a cheat sheet!](https://rstudio.com/resources/cheatsheets/) <img src="images/lubridate.png" alt="" height="150"/>] --- class: inverse .sectionhead[Part 4: Regular Expressions] --- layout: true # Regular Expressions --- Many, many thanks to the developers of `stringr`, who developed these excellent demonstrations of regular expressions. --- Recall that strings in R are characters grouped together within double quotes `""` or single quotes `''`. However, there are characters that cannot be represented directly in an R string. For example, what if your string contains a double quote, or a line break? A line break in R is done using the regular expression `\n`. For example: ```r cat("Line 1\nLine 2") ``` ``` ## Line 1 ## Line 2 ``` However, with regular expressions, the backslash `\` is a special character. Thus, in order to have `\` within a regular expression, we must precede the backslash with its own backslash! For example, the regular expression `\\` matches the string `\`. Thus, if we want to use a new line in a regular expression, we need to type `\\n`, giving us `\n`. Confusing? Don't worry, we will go through many examples. --- ```r see <- function(rx) { str_extract_all("abc ABC 123\t.!?\\(){}\n", rx) %>% unlist() %>% str_c(collapse = "") } print("abc ABC 123\t.!?\\(){}\n") ``` ``` ## [1] "abc ABC 123\t.!?\\(){}\n" ``` ```r see("a") ``` ``` ## [1] "a" ``` --- ```r see(".") ``` ``` ## [1] "abc ABC 123\t.!?\\(){}" ``` What happened here? `.` is a special character in a regular expression, meaning every character except a new line. If we want to search for `.` ```r see("\\.") ``` ``` ## [1] "." ``` ```r see("?") ``` ``` ## Error in stri_extract_all_regex(string, pattern, simplify = simplify, : Syntax error in regexp pattern. (U_REGEX_RULE_SYNTAX, context=`?`) ``` `?` is also special character. So to search for that symbol ```r see("\\?") ``` ``` ## [1] "?" ``` --- Similarly for other special characters. ```r see("\\}") ``` ``` ## [1] "}" ``` ```r see("\\(") ``` ``` ## [1] "(" ``` What if we want to search for the backslash itself? ```r see("\\\\") ``` ``` ## [1] "\\" ``` --- We can search for special commands, such as... * new line `\n` ```r see("\\n") ``` ``` ## [1] "\n" ``` * Tabs `\t` ```r see("\\t") ``` ``` ## [1] "\t" ``` * Any white spaces `\s` ```r see("\\s") ``` ``` ## [1] " \t\n" ``` --- * Any digit `\d` ```r see("\\d") ``` ``` ## [1] "123" ``` * Any word character `\w` ```r see("\\w") ``` ``` ## [1] "abcABC123" ``` * Any boundaries `\b` ```r see("\\b") ``` ``` ## [1] "" ``` (note this doesn't return any characters, but try it with `str_view()` in your console) --- We can search for groups of characters such as * digits `[:digit:]` ```r see("[:digit:]") ``` ``` ## [1] "123" ``` * letters `[:alpha:]` ```r see("[:alpha:]") ``` ``` ## [1] "abcABC" ``` * letters and numbers `[:alnum:]` ```r see("[:alnum:]") ``` ``` ## [1] "abcABC123" ``` --- * lowercase letters `[:lower:]` ```r see("[:lower:]") ``` ``` ## [1] "abc" ``` * uppercase letters `[:upper:]` ```r see("[:upper:]") ``` ``` ## [1] "ABC" ``` * punctuation `[:punct:]` ```r see("[:punct:]") ``` ``` ## [1] ".!?\\(){}" ``` --- * letters, numbers, and punctuation `[:graph:]` ```r see("[:graph:]") ``` ``` ## [1] "abcABC123.!?\\(){}" ``` * space characters `[:space:]` ```r see("[:space:]") ``` ``` ## [1] " \t\n" ``` * space and tab (not new line) `[:blank:]` ```r see("[:blank:]") ``` ``` ## [1] " \t" ``` --- ## Alternates ```r alt <- function(rx) { str_extract_all("abcde", rx) %>% unlist() %>% str_c(collapse = "") } ``` * or `|` ```r alt("a|e") ``` ``` ## [1] "ae" ``` ```r alt("ab|d") ``` ``` ## [1] "abd" ``` --- ## Alternates * one of `[bae]` ```r alt("[bae]") ``` ``` ## [1] "abe" ``` * anything but `[^bae]` ```r alt("[^bae]") ``` ``` ## [1] "cd" ``` * range of values `[a-c]` ```r alt("[a-c]") ``` ``` ## [1] "abc" ```