∑ { my parts }

library(tidyverse)

terrorists <- googlesheets::gs_url("https://docs.google.com/spreadsheets/d/1LYQakIwGosibDHJKJqZgjM39qpSlp_gFG29zJ6paDAI/edit#gid=956062857") %>% 
  googlesheets::gs_read()

terrorist_by_race
## # A tibble: 7 x 6
##   race                n fatalities injured total_victims   `%`
##   <chr>           <int>      <dbl>   <dbl>         <dbl> <dbl>
## 1 white              63        554    1067          1621 69.3 
## 2 other               5         90     115           205  8.77
## 3 black              19        108      89           197  8.43
## 4 asian               8         77      33           110  4.70
## 5 unclear             6         40      61           101  4.32
## 6 latino             10         44      33            77  3.29
## 7 native american     3         19       8            27  1.15

terrorist_by_gender
## # A tibble: 3 x 6
##   gender            n fatalities injured total_victims    `%`
##   <chr>         <int>      <dbl>   <dbl>         <dbl>  <dbl>
## 1 male            110        903    1380          2283 97.6  
## 2 male & female     1         14      21            35  1.50 
## 3 female            3         15       5            20  0.855
terrorist <- c("angry", "white", "male")
my_parts <- c("angry", "white", "male")
my_parts == terrorist
## [1] TRUE TRUE TRUE
`I am` > sum(my_parts)
## [1] TRUE
`I am` == sum(terrorist)
FALSE
## [1] FALSE
white_males <- filter(terrorists,
                      race == "white",
                      tolower(gender) == "male",
                      !is.na(name))

pull(white_males, name)
##  [1] "Jordan Witmer"             "Zephen A. Xaver"          
##  [3] "Robert D. Bowers"          "Jarrod W. Ramos"          
##  [5] "Dimitrios Pagourtzis"      "Travis Reinking"          
##  [7] "Nikolas J. Cruz"           "Timothy O'Brien Smith"    
##  [9] "Kevin Janson Neal"         "Devin Patrick Kelley"     
## [11] "Scott Allen Ostrem"        "Stephen Craig Paddock"    
## [13] "Randy Stair"               "Thomas Hartless"          
## [15] "Jason B. Dalton"           "Robert Lewis Dear"        
## [17] "Noah Harpham"              "Dylann Storm Roof"        
## [19] "Elliot Rodger"             "John Zawahri"             
## [21] "Kurt Myers"                "Adam Lanza"               
## [23] "Andrew Engeldinger"        "Wade Michael Page"        
## [25] "James Holmes"              "Ian Stawicki"             
## [27] "Scott Evans Dekraai"       "Jared Loughner"           
## [29] "Robert Stewart"            "Wesley Neal Higdon"       
## [31] "Steven Kazmierczak"        "Robert A. Hawkins"        
## [33] "Tyler Peterson"            "Sulejman Talović\u0087"   
## [35] "Charles Carl Roberts"      "Kyle Aaron Huff"          
## [37] "Terry Michael Ratzmann"    "Nathan Gale"              
## [39] "Douglas Williams"          "Michael McDermott"        
## [41] "Larry Gene Ashbrook"       "Day trader Mark O. Barton"
## [43] "Eric Harris"               "Kipland P. Kinkel"        
## [45] "Mitchell Scott Johnson"    "Matthew Beck"             
## [47] "Dean Allen Mellberg"       "Kenneth Junior French"    
## [49] "Gian Luigi Ferri"          "John T. Miller"           
## [51] "Eric Houston"              "Thomas McIlvane"          
## [53] "George Hennard"            "Joseph T. Wesbecker"      
## [55] "Patrick Purdy"             "Richard Farley"           
## [57] "William Cruse"             "Patrick Sherrill"         
## [59] "James Oliver Huberty"      "Abdelkrim Belachheb"      
## [61] "Carl Robert Brown"
am_i <- function(terrorist) {
  msg <- paste("am i ==", terrorist)
  print(msg)
  print(`am i` == terrorist)
}
pull(white_males, name) %>% 
  walk(~am_i(.))
## [1] "`am i` == Jordan Witmer"
## [1] FALSE
## [1] "`am i` == Zephen A. Xaver"
## [1] FALSE
## [1] "`am i` == Robert D. Bowers"
## [1] FALSE
## [1] "`am i` == Jarrod W. Ramos"
## [1] FALSE
## [1] "`am i` == Dimitrios Pagourtzis"
## [1] FALSE
## [1] "`am i` == Travis Reinking"
## [1] FALSE
## [1] "`am i` == Nikolas J. Cruz"
## [1] FALSE
## [1] "`am i` == Timothy O'Brien Smith"
## [1] FALSE
## [1] "`am i` == Kevin Janson Neal"
## [1] FALSE
## [1] "`am i` == Devin Patrick Kelley"
## [1] FALSE
## [1] "`am i` == Scott Allen Ostrem"
## [1] FALSE
## [1] "`am i` == Stephen Craig Paddock"
## [1] FALSE
## [1] "`am i` == Randy Stair"
## [1] FALSE
## [1] "`am i` == Thomas Hartless"
## [1] FALSE
## [1] "`am i` == Jason B. Dalton"
## [1] FALSE
## [1] "`am i` == Robert Lewis Dear"
## [1] FALSE
## [1] "`am i` == Noah Harpham"
## [1] FALSE
## [1] "`am i` == Dylann Storm Roof"
## [1] FALSE
## [1] "`am i` == Elliot Rodger"
## [1] FALSE
## [1] "`am i` == John Zawahri"
## [1] FALSE
## [1] "`am i` == Kurt Myers"
## [1] FALSE
## [1] "`am i` == Adam Lanza"
## [1] FALSE
## [1] "`am i` == Andrew Engeldinger"
## [1] FALSE
## [1] "`am i` == Wade Michael Page"
## [1] FALSE
## [1] "`am i` == James Holmes"
## [1] FALSE
## [1] "`am i` == Ian Stawicki"
## [1] FALSE
## [1] "`am i` == Scott Evans Dekraai"
## [1] FALSE
## [1] "`am i` == Jared Loughner"
## [1] FALSE
## [1] "`am i` == Robert Stewart"
## [1] FALSE
## [1] "`am i` == Wesley Neal Higdon"
## [1] FALSE
## [1] "`am i` == Steven Kazmierczak"
## [1] FALSE
## [1] "`am i` == Robert A. Hawkins"
## [1] FALSE
## [1] "`am i` == Tyler Peterson"
## [1] FALSE
## [1] "`am i` == Sulejman Talović\u0087"
## [1] FALSE
## [1] "`am i` == Charles Carl Roberts"
## [1] FALSE
## [1] "`am i` == Kyle Aaron Huff"
## [1] FALSE
## [1] "`am i` == Terry Michael Ratzmann"
## [1] FALSE
## [1] "`am i` == Nathan Gale"
## [1] FALSE
## [1] "`am i` == Douglas Williams"
## [1] FALSE
## [1] "`am i` == Michael McDermott"
## [1] FALSE
## [1] "`am i` == Larry Gene Ashbrook"
## [1] FALSE
## [1] "`am i` == Day trader Mark O. Barton"
## [1] FALSE
## [1] "`am i` == Eric Harris"
## [1] FALSE
## [1] "`am i` == Kipland P. Kinkel"
## [1] FALSE
## [1] "`am i` == Mitchell Scott Johnson"
## [1] FALSE
## [1] "`am i` == Matthew Beck"
## [1] FALSE
## [1] "`am i` == Dean Allen Mellberg"
## [1] FALSE
## [1] "`am i` == Kenneth Junior French"
## [1] FALSE
## [1] "`am i` == Gian Luigi Ferri"
## [1] FALSE
## [1] "`am i` == John T. Miller"
## [1] FALSE
## [1] "`am i` == Eric Houston"
## [1] FALSE
## [1] "`am i` == Thomas McIlvane"
## [1] FALSE
## [1] "`am i` == George Hennard"
## [1] FALSE
## [1] "`am i` == Joseph T. Wesbecker"
## [1] FALSE
## [1] "`am i` == Patrick Purdy"
## [1] FALSE
## [1] "`am i` == Richard Farley"
## [1] FALSE
## [1] "`am i` == William Cruse"
## [1] FALSE
## [1] "`am i` == Patrick Sherrill"
## [1] FALSE
## [1] "`am i` == James Oliver Huberty"
## [1] FALSE
## [1] "`am i` == Abdelkrim Belachheb"
## [1] FALSE
## [1] "`am i` == Carl Robert Brown"
## [1] FALSE
`I am` > sum(my_parts)
Avatar
Josiah Parry
Social Data Scientist

Related