Import your data

Data <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-11-29/wcmatches.csv')
## Rows: 900 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): country, city, stage, home_team, away_team, outcome, win_conditio...
## dbl   (3): year, home_score, away_score
## date  (1): date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Chapter 14

Tools

Detect matches

Data$home_team
##   [1] "France"                 "Belgium"                "Brazil"                
##   [4] "Peru"                   "Argentina"              "Chile"                 
##   [7] "Bolivia"                "Paraguay"               "Uruguay"               
##  [10] "Argentina"              "Chile"                  "Belgium"               
##  [13] "Bolivia"                "Uruguay"                "Argentina"             
##  [16] "Argentina"              "Uruguay"                "Uruguay"               
##  [19] "Argentina"              "Austria"                "Belgium"               
##  [22] "Brazil"                 "Czechoslovakia"         "Egypt"                 
##  [25] "Italy"                  "Netherlands"            "Austria"               
##  [28] "Czechoslovakia"         "Germany"                "Italy"                 
##  [31] "Italy"                  "Czechoslovakia"         "Italy"                 
##  [34] "Austria"                "Italy"                  "Germany"               
##  [37] "Brazil"                 "Cuba"                   "Czechoslovakia"        
##  [40] "France"                 "Hungary"                "Italy"                 
##  [43] "Cuba"                   "Germany"                "Brazil"                
##  [46] "Cuba"                   "France"                 "Hungary"               
##  [49] "Brazil"                 "Brazil"                 "Hungary"               
##  [52] "Brazil"                 "Hungary"                "Brazil"                
##  [55] "Chile"                  "Italy"                  "Spain"                 
##  [58] "Switzerland"            "Brazil"                 "Mexico"                
##  [61] "Chile"                  "England"                "Paraguay"              
##  [64] "Brazil"                 "Bolivia"                "Chile"                 
##  [67] "England"                "Italy"                  "Mexico"                
##  [70] "Brazil"                 "Spain"                  "Brazil"                
##  [73] "Sweden"                 "Brazil"                 "Spain"                 
##  [76] "Austria"                "Brazil"                 "Czechoslovakia"        
##  [79] "France"                 "Belgium"                "West Germany"          
##  [82] "Hungary"                "Switzerland"            "Austria"               
##  [85] "Brazil"                 "France"                 "Scotland"              
##  [88] "Belgium"                "West Germany"           "South Korea"           
##  [91] "Switzerland"            "West Germany"           "Switzerland"           
##  [94] "England"                "Switzerland"            "Brazil"                
##  [97] "West Germany"           "Austria"                "Hungary"               
## [100] "Austria"                "West Germany"           "Argentina"             
## [103] "Austria"                "Czechoslovakia"         "England"               
## [106] "France"                 "Hungary"                "Scotland"              
## [109] "Sweden"                 "Argentina"              "Austria"               
## [112] "Brazil"                 "Czechoslovakia"         "France"                
## [115] "Mexico"                 "Paraguay"               "Sweden"                
## [118] "Argentina"              "Austria"                "Brazil"                
## [121] "France"                 "West Germany"           "Hungary"               
## [124] "Paraguay"               "Sweden"                 "Czechoslovakia"        
## [127] "England"                "Hungary"                "Brazil"                
## [130] "France"                 "West Germany"           "Sweden"                
## [133] "Brazil"                 "Sweden"                 "France"                
## [136] "Sweden"                 "Argentina"              "Brazil"                
## [139] "Chile"                  "Colombia"               "Czechoslovakia"        
## [142] "England"                "West Germany"           "Soviet Union"          
## [145] "Argentina"              "Brazil"                 "Chile"                 
## [148] "Uruguay"                "Bulgaria"               "Colombia"              
## [151] "West Germany"           "Mexico"                 "Argentina"             
## [154] "Brazil"                 "Chile"                  "Soviet Union"          
## [157] "Bulgaria"               "Colombia"               "Czechoslovakia"        
## [160] "Italy"                  "Brazil"                 "Chile"                 
## [163] "Czechoslovakia"         "West Germany"           "Chile"                 
## [166] "Czechoslovakia"         "Chile"                  "Brazil"                
## [169] "England"                "Brazil"                 "West Germany"          
## [172] "North Korea"            "Argentina"              "Chile"                 
## [175] "France"                 "Hungary"                "Brazil"                
## [178] "Chile"                  "France"                 "Spain"                 
## [181] "Argentina"              "Bulgaria"               "England"               
## [184] "Italy"                  "Argentina"              "Brazil"                
## [187] "Italy"                  "Mexico"                 "Bulgaria"              
## [190] "Chile"                  "England"                "West Germany"          
## [193] "England"                "West Germany"           "Hungary"               
## [196] "North Korea"            "West Germany"           "England"               
## [199] "Portugal"               "England"                "Mexico"                
## [202] "Bulgaria"               "England"                "Israel"                
## [205] "Belgium"                "Brazil"                 "West Germany"          
## [208] "Italy"                  "Belgium"                "Czechoslovakia"        
## [211] "Italy"                  "Morocco"                "Brazil"                
## [214] "Bulgaria"               "Israel"                 "Mexico"                
## [217] "Brazil"                 "El Salvador"            "West Germany"          
## [220] "Sweden"                 "Bulgaria"               "Czechoslovakia"        
## [223] "Israel"                 "Mexico"                 "Brazil"                
## [226] "England"                "Mexico"                 "Soviet Union"          
## [229] "Brazil"                 "West Germany"           "West Germany"          
## [232] "Brazil"                 "Brazil"                 "Zaire"                 
## [235] "East Germany"           "West Germany"           "Italy"                 
## [238] "Poland"                 "Sweden"                 "Uruguay"               
## [241] "Chile"                  "West Germany"           "Scotland"              
## [244] "Yugoslavia"             "Argentina"              "Bulgaria"              
## [247] "Haiti"                  "Netherlands"            "Australia"             
## [250] "Zaire"                  "West Germany"           "Scotland"              
## [253] "Argentina"              "Bulgaria"               "Poland"                
## [256] "Sweden"                 "Brazil"                 "West Germany"          
## [259] "Netherlands"            "Sweden"                 "Argentina"             
## [262] "East Germany"           "West Germany"           "Poland"                
## [265] "Argentina"              "West Germany"           "Netherlands"           
## [268] "Sweden"                 "Brazil"                 "West Germany"          
## [271] "West Germany"           "Argentina"              "France"                
## [274] "Mexico"                 "Austria"                "Brazil"                
## [277] "Iran"                   "Peru"                   "Argentina"             
## [280] "West Germany"           "Hungary"                "Poland"                
## [283] "Austria"                "Brazil"                 "Iran"                  
## [286] "Netherlands"            "Argentina"              "France"                
## [289] "West Germany"           "Mexico"                 "Austria"               
## [292] "Iran"                   "Netherlands"            "Spain"                 
## [295] "Argentina"              "Austria"                "Brazil"                
## [298] "West Germany"           "Argentina"              "Austria"               
## [301] "West Germany"           "Peru"                   "Argentina"             
## [304] "Austria"                "Brazil"                 "Italy"                 
## [307] "Brazil"                 "Argentina"              "Argentina"             
## [310] "Brazil"                 "Italy"                  "Hungary"               
## [313] "Peru"                   "Scotland"               "England"               
## [316] "West Germany"           "Spain"                  "Chile"                 
## [319] "Czechoslovakia"         "Yugoslavia"             "Argentina"             
## [322] "Brazil"                 "Italy"                  "Belgium"               
## [325] "Poland"                 "Soviet Union"           "England"               
## [328] "West Germany"           "Spain"                  "Algeria"               
## [331] "France"                 "Honduras"               "Belgium"               
## [334] "Poland"                 "Soviet Union"           "Argentina"             
## [337] "Brazil"                 "Italy"                  "Algeria"               
## [340] "France"                 "Honduras"               "England"               
## [343] "West Germany"           "Spain"                  "Austria"               
## [346] "Poland"                 "West Germany"           "Italy"                 
## [349] "Austria"                "Belgium"                "Argentina"             
## [352] "Spain"                  "France"                 "Poland"                
## [355] "Italy"                  "Spain"                  "West Germany"          
## [358] "Poland"                 "Poland"                 "Italy"                 
## [361] "Bulgaria"               "Canada"                 "Spain"                 
## [364] "Argentina"              "Morocco"                "Soviet Union"          
## [367] "Algeria"                "Mexico"                 "Portugal"              
## [370] "Paraguay"               "Scotland"               "Uruguay"               
## [373] "France"                 "Italy"                  "South Korea"           
## [376] "Brazil"                 "England"                "Hungary"               
## [379] "Mexico"                 "Northern Ireland"       "Poland"                
## [382] "Denmark"                "West Germany"           "Iraq"                  
## [385] "Hungary"                "Soviet Union"           "Argentina"             
## [388] "South Korea"            "England"                "Mexico"                
## [391] "Paraguay"               "Portugal"               "Algeria"               
## [394] "Northern Ireland"       "Denmark"                "Scotland"              
## [397] "Mexico"                 "Soviet Union"           "Argentina"             
## [400] "Brazil"                 "Italy"                  "Morocco"               
## [403] "Denmark"                "England"                "Brazil"                
## [406] "Mexico"                 "Argentina"              "Spain"                 
## [409] "Argentina"              "France"                 "France"                
## [412] "Argentina"              "Argentina"              "Italy"                 
## [415] "Soviet Union"           "United Arab Emirates"   "Brazil"                
## [418] "West Germany"           "United States"          "Costa Rica"            
## [421] "England"                "Belgium"                "Netherlands"           
## [424] "Argentina"              "Uruguay"                "Cameroon"              
## [427] "Italy"                  "Yugoslavia"             "Austria"               
## [430] "West Germany"           "Brazil"                 "England"               
## [433] "Sweden"                 "Belgium"                "Republic of Ireland"   
## [436] "South Korea"            "Argentina"              "Cameroon"              
## [439] "Austria"                "West Germany"           "Italy"                 
## [442] "Yugoslavia"             "Brazil"                 "Sweden"                
## [445] "Belgium"                "England"                "Republic of Ireland"   
## [448] "South Korea"            "Cameroon"               "Czechoslovakia"        
## [451] "Brazil"                 "West Germany"           "Republic of Ireland"   
## [454] "Italy"                  "England"                "Spain"                 
## [457] "Italy"                  "Yugoslavia"             "Cameroon"              
## [460] "West Germany"           "Italy"                  "West Germany"          
## [463] "Italy"                  "West Germany"           "Germany"               
## [466] "Spain"                  "Colombia"               "Italy"                 
## [469] "United States"          "Belgium"                "Cameroon"              
## [472] "Norway"                 "Brazil"                 "Netherlands"           
## [475] "Argentina"              "Germany"                "Nigeria"               
## [478] "Romania"                "United States"          "Italy"                 
## [481] "South Korea"            "Brazil"                 "Mexico"                
## [484] "Sweden"                 "Argentina"              "Belgium"               
## [487] "Saudi Arabia"           "Bulgaria"               "Switzerland"           
## [490] "United States"          "Bolivia"                "Germany"               
## [493] "Brazil"                 "Republic of Ireland"    "Italy"                 
## [496] "Russia"                 "Belgium"                "Morocco"               
## [499] "Argentina"              "Greece"                 "Germany"               
## [502] "Spain"                  "Romania"                "Saudi Arabia"          
## [505] "Netherlands"            "United States"          "Mexico"                
## [508] "Nigeria"                "Italy"                  "Netherlands"           
## [511] "Bulgaria"               "Romania"                "Bulgaria"              
## [514] "Sweden"                 "Sweden"                 "Brazil"                
## [517] "Brazil"                 "Morocco"                "Cameroon"              
## [520] "Italy"                  "France"                 "Paraguay"              
## [523] "Saudi Arabia"           "South Korea"            "Netherlands"           
## [526] "Spain"                  "Argentina"              "Jamaica"               
## [529] "FR Yugoslavia"          "England"                "Germany"               
## [532] "Romania"                "Brazil"                 "Scotland"              
## [535] "Chile"                  "Italy"                  "France"                
## [538] "South Africa"           "Nigeria"                "Spain"                 
## [541] "Belgium"                "Japan"                  "Netherlands"           
## [544] "Argentina"              "Germany"                "United States"         
## [547] "Colombia"               "Romania"                "Brazil"                
## [550] "Chile"                  "Italy"                  "Scotland"              
## [553] "France"                 "Nigeria"                "South Africa"          
## [556] "Spain"                  "Belgium"                "Germany"               
## [559] "Netherlands"            "United States"          "Argentina"             
## [562] "Colombia"               "Japan"                  "Romania"               
## [565] "Brazil"                 "Italy"                  "France"                
## [568] "Nigeria"                "Germany"                "Netherlands"           
## [571] "Argentina"              "Romania"                "Brazil"                
## [574] "France"                 "Germany"                "Netherlands"           
## [577] "Brazil"                 "France"                 "Netherlands"           
## [580] "France"                 "France"                 "Germany"               
## [583] "Republic of Ireland"    "Uruguay"                "Argentina"             
## [586] "England"                "Paraguay"               "Spain"                 
## [589] "Brazil"                 "Croatia"                "Italy"                 
## [592] "China PR"               "Japan"                  "South Korea"           
## [595] "Germany"                "Russia"                 "United States"         
## [598] "Cameroon"               "Denmark"                "France"                
## [601] "Argentina"              "Spain"                  "Sweden"                
## [604] "Brazil"                 "Italy"                  "South Africa"          
## [607] "Costa Rica"             "Japan"                  "Mexico"                
## [610] "South Korea"            "Portugal"               "Tunisia"               
## [613] "Cameroon"               "Denmark"                "Saudi Arabia"          
## [616] "Senegal"                "Nigeria"                "Slovenia"              
## [619] "South Africa"           "Sweden"                 "Costa Rica"            
## [622] "Ecuador"                "Mexico"                 "Turkey"                
## [625] "Belgium"                "Japan"                  "South Korea"           
## [628] "Poland"                 "Denmark"                "Germany"               
## [631] "Spain"                  "Sweden"                 "Brazil"                
## [634] "Mexico"                 "Japan"                  "South Korea"           
## [637] "England"                "Germany"                "South Korea"           
## [640] "Senegal"                "South Korea"            "Brazil"                
## [643] "South Korea"            "Germany"                "Germany"               
## [646] "Poland"                 "Argentina"              "England"               
## [649] "Trinidad and Tobago"    "Angola"                 "Mexico"                
## [652] "Serbia"                 "Australia"              "Italy"                 
## [655] "United States"          "Brazil"                 "France"                
## [658] "South Korea"            "Germany"                "Spain"                 
## [661] "Tunisia"                "Ecuador"                "England"               
## [664] "Sweden"                 "Argentina"              "Mexico"                
## [667] "Netherlands"            "Czech Republic"         "Italy"                 
## [670] "Portugal"               "Brazil"                 "France"                
## [673] "Japan"                  "Saudi Arabia"           "Spain"                 
## [676] "Togo"                   "Costa Rica"             "Germany"               
## [679] "Paraguay"               "Sweden"                 "Iran"                  
## [682] "Ivory Coast"            "Netherlands"            "Portugal"              
## [685] "Croatia"                "Czech Republic"         "Ghana"                 
## [688] "Japan"                  "Saudi Arabia"           "Switzerland"           
## [691] "Togo"                   "Ukraine"                "Argentina"             
## [694] "Germany"                "England"                "Portugal"              
## [697] "Italy"                  "Switzerland"            "Brazil"                
## [700] "Spain"                  "Germany"                "Italy"                 
## [703] "Brazil"                 "England"                "Germany"               
## [706] "Portugal"               "Germany"                "Italy"                 
## [709] "South Africa"           "Uruguay"                "Argentina"             
## [712] "England"                "South Korea"            "Algeria"               
## [715] "Germany"                "Serbia"                 "Italy"                 
## [718] "Japan"                  "Netherlands"            "Brazil"                
## [721] "Ivory Coast"            "New Zealand"            "Honduras"              
## [724] "South Africa"           "Spain"                  "Argentina"             
## [727] "France"                 "Greece"                 "England"               
## [730] "Germany"                "Slovenia"               "Cameroon"              
## [733] "Ghana"                  "Netherlands"            "Brazil"                
## [736] "Italy"                  "Slovakia"               "Chile"                 
## [739] "Portugal"               "Spain"                  "Greece"                
## [742] "Mexico"                 "Nigeria"                "South Africa"          
## [745] "Australia"              "Ghana"                  "Slovenia"              
## [748] "United States"          "Cameroon"               "Denmark"               
## [751] "Paraguay"               "Slovakia"               "Chile"                 
## [754] "North Korea"            "Portugal"               "Switzerland"           
## [757] "Uruguay"                "United States"          "Argentina"             
## [760] "Germany"                "Brazil"                 "Netherlands"           
## [763] "Paraguay"               "Spain"                  "Netherlands"           
## [766] "Uruguay"                "Argentina"              "Paraguay"              
## [769] "Uruguay"                "Germany"                "Uruguay"               
## [772] "Netherlands"            "Brazil"                 "Chile"                 
## [775] "Mexico"                 "Spain"                  "Colombia"              
## [778] "England"                "Ivory Coast"            "Uruguay"               
## [781] "Argentina"              "France"                 "Switzerland"           
## [784] "Germany"                "Ghana"                  "Iran"                  
## [787] "Belgium"                "Brazil"                 "Russia"                
## [790] "Australia"              "Cameroon"               "Spain"                 
## [793] "Colombia"               "Japan"                  "Uruguay"               
## [796] "Honduras"               "Italy"                  "Switzerland"           
## [799] "Argentina"              "Germany"                "Nigeria"               
## [802] "Belgium"                "South Korea"            "United States"         
## [805] "Australia"              "Brazil"                 "Croatia"               
## [808] "Netherlands"            "Costa Rica"             "Greece"                
## [811] "Italy"                  "Japan"                  "Bosnia and Herzegovina"
## [814] "Ecuador"                "Honduras"               "Nigeria"               
## [817] "Algeria"                "South Korea"            "Portugal"              
## [820] "United States"          "Brazil"                 "Colombia"              
## [823] "Costa Rica"             "Netherlands"            "France"                
## [826] "Germany"                "Argentina"              "Belgium"               
## [829] "Brazil"                 "France"                 "Argentina"             
## [832] "Netherlands"            "Brazil"                 "Netherlands"           
## [835] "Brazil"                 "Germany"                "Russia"                
## [838] "Egypt"                  "Morocco"                "Portugal"              
## [841] "France"                 "Argentina"              "Peru"                  
## [844] "Croatia"                "Costa Rica"             "Germany"               
## [847] "Brazil"                 "Sweden"                 "Belgium"               
## [850] "Tunisia"                "Colombia"               "Poland"                
## [853] "Russia"                 "Portugal"               "Uruguay"               
## [856] "Iran"                   "Denmark"                "France"                
## [859] "Argentina"              "Brazil"                 "Nigeria"               
## [862] "Serbia"                 "Belgium"                "South Korea"           
## [865] "Germany"                "England"                "Japan"                 
## [868] "Poland"                 "Russia"                 "Saudi Arabia"          
## [871] "Spain"                  "Iran"                   "Australia"             
## [874] "Denmark"                "Nigeria"                "Iceland"               
## [877] "South Korea"            "Mexico"                 "Serbia"                
## [880] "Switzerland"            "Japan"                  "Senegal"               
## [883] "Panama"                 "England"                "France"                
## [886] "Uruguay"                "Russia"                 "Croatia"               
## [889] "Brazil"                 "Belgium"                "Sweden"                
## [892] "Colombia"               "Uruguay"                "Brazil"                
## [895] "Sweden"                 "Russia"                 "France"                
## [898] "Croatia"                "Belgium"                "France"
str_detect(Data$home_team, "Brazil")
##   [1] FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE
##  [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [37]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
##  [49]  TRUE  TRUE FALSE  TRUE FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE
##  [61] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE
##  [73] FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [85]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
##  [97] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [109] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
## [121] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
## [133]  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
## [145] FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE
## [157] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
## [169] FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
## [181] FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
## [193] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [205] FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
## [217]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
## [229]  TRUE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [241] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [253] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [265] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
## [277] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
## [289] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
## [301] FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE
## [313] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE
## [325] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [337]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [349] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [361] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [373] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [385] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [397] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
## [409] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
## [421] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE
## [433] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE
## [445] FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE
## [457] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [469] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [481] FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [493]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [505] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
## [517]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [529] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [541] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
## [553] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [565]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
## [577]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [589]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [601] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [613] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [625] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
## [637] FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
## [649] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
## [661] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE
## [673] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [685] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [697] FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE
## [709] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
## [721] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [733] FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [745] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [757] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [769] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [781] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
## [793] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [805] FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [817] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [829]  TRUE FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE
## [841] FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE
## [853] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
## [865] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [877] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [889]  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
sum(str_detect(Data$home_team, "Brazil"))
## [1] 84
Data %>% 
    summarise(num_Brazil = sum(str_detect(home_team, "Brazil")))
## # A tibble: 1 × 1
##   num_Brazil
##        <int>
## 1         84

Extract matches

Data %>%
    mutate(col_Brazil = str_extract(home_team, "Brazil")) %>%
    select(home_team, col_Brazil) %>%
    filter(!is.na(col_Brazil))
## # A tibble: 84 × 2
##    home_team col_Brazil
##    <chr>     <chr>     
##  1 Brazil    Brazil    
##  2 Brazil    Brazil    
##  3 Brazil    Brazil    
##  4 Brazil    Brazil    
##  5 Brazil    Brazil    
##  6 Brazil    Brazil    
##  7 Brazil    Brazil    
##  8 Brazil    Brazil    
##  9 Brazil    Brazil    
## 10 Brazil    Brazil    
## # ℹ 74 more rows

Replacing matches

Data %>%
    mutate(col_Argentina = str_replace(home_team, "Brazil", "Argentina")) %>%
    select(home_team, col_Argentina)
## # A tibble: 900 × 2
##    home_team col_Argentina
##    <chr>     <chr>        
##  1 France    France       
##  2 Belgium   Belgium      
##  3 Brazil    Argentina    
##  4 Peru      Peru         
##  5 Argentina Argentina    
##  6 Chile     Chile        
##  7 Bolivia   Bolivia      
##  8 Paraguay  Paraguay     
##  9 Uruguay   Uruguay      
## 10 Argentina Argentina    
## # ℹ 890 more rows