Introduction

The buddy cop films have a plot with two conflicting personalities who are out to solve a crime or defeat some criminals. The partners always seem to be of different ethnicity and I wanted to see what was the most popular.

Data

The movie list was gathered from the Buddy cop film Wikipedia page, specifically the American buddy cop films. Since sequels are popular (Rush Hour, Die Hard, Bad Boys, etc.), only the first movie will be considered, although buddies may change in subsequent films.

library(rvest)

page <- read_html("https://en.wikipedia.org/wiki/Buddy_cop_film")
amFilms <- page %>% html_nodes("ul:nth-child(13) i a")
movTitle <- amFilms %>% html_text # Western Films
wikiLink <- paste0("https://en.wikipedia.org",amFilms %>% html_attr("href"))
df.mov <- data.frame(title=movTitle, wiki.link=wikiLink, stringsAsFactors=F)

# Need to remove sequels - though buddies may change in sequels (Die Hard), I'm going to say that they dont
df.mov <- df.mov[-which(df.mov$title == "Bad Boys II"),]
df.mov <- df.mov[-which(df.mov$title == "22 Jump Street"),]
df.mov <- df.mov[-which(df.mov$title == "Another 48 Hrs."),]
df.mov <- df.mov[-which(df.mov$title == "Ride Along 2"),]
df.mov <- df.mov[-which(df.mov$title == "Die Hard with a Vengeance"),]
df.mov <- df.mov[-which(df.mov$title == "Live Free or Die Hard"),]

To get the actor/actress in the movie, the link obtained above will be used to visit the film page and the first two in “Starring” will be used as buddy 1 and buddy 2. Since the buddies are the main stars, they are listed on the movie poster which the ‘movie infobox’ on Wikipedia uses. Unfortunately, using a table does not work for all pages as the format is slightly different between a few of the movie pages and caused to many issues. The way below captures most of the data needed after making a few edits to the respective Wikipedia page. Some manual edits will be needed for buddy animal movies such as K-9 and Turner and Hooch where the animal is not always listed but another actor/actress.

# put in buddies
df.mov$buddy.1 <- NA
df.mov$buddy.2 <- NA
base.node <- "#mw-content-text > table.infobox.vevent > tr"
for (k in 1:nrow(df.mov)) {
  page <- read_html(df.mov$wiki.link[k])
  star.node <- grep("Starring\n", page %>% html_nodes(base.node) %>% html_text) # Get node to create further
  buddies <- page %>% html_node(paste0(base.node, ":nth-child(", star.node, ")")) %>% html_nodes("a") %>% html_text # Extract buddies
  df.mov$buddy.1[k] <- buddies[1]
  df.mov$buddy.2[k] <- buddies[2]
  Sys.sleep(0.5)
}

# Fix a few movies
df.mov$buddy.2[df.mov$title == "The Other Guys"] <- "Will Ferrel"
df.mov$buddy.2[df.mov$title == "Skiptrace"] <- "Jimmy Fallon"

The following actor/actoress are given:

  title wiki.link buddy.1 buddy.2
1 In the Heat of the Night Link Sidney Poitier Rod Steiger
2 Coogan’s Bluff Link Clint Eastwood Lee J. Cobb
3 Hickey & Boggs Link Bill Cosby Robert Culp
4 Brannigan Link John Wayne Richard Attenborough
5 The Gauntlet Link Clint Eastwood Sondra Locke
6 48 Hrs. Link Nick Nolte Eddie Murphy
8 Partners Link Ryan O’Neal John Hurt
9 City Heat Link Clint Eastwood Burt Reynolds
10 Beverly Hills Cop Link Eddie Murphy NA
11 Murphy’s Law Link Charles Bronson Carrie Snodgress
12 Armed and Dangerous Link John Candy Eugene Levy
13 Running Scared Link Gregory Hines Billy Crystal
14 Lethal Weapon Link Mel Gibson Danny Glover
15 Dragnet Link Tom Hanks Christopher Plummer
16 The Hidden Link Michael Nouri Kyle MacLachlan
17 Stakeout Link Richard Dreyfuss Emilio Estevez
18 Another Stakeout Link Richard Dreyfuss Emilio Estevez
19 Midnight Run Link Robert De Niro Charles Grodin
20 Shoot to Kill Link Sidney Poitier Tom Berenger
21 Heart Condition Link Bob Hoskins Denzel Washington
22 Colors Link Sean Penn Robert Duvall
23 Red Heat Link Arnold Schwarzenegger James Belushi
26 A Good Day to Die Hard Link Bruce Willis Jai Courtney
27 Alien Nation Link James Caan Mandy Patinkin
28 Taxi Link Queen Latifah Jimmy Fallon
29 Collision Course Link Jay Leno Pat Morita
30 K-9 Link James Belushi Mel Harris
31 Renegades Link Kiefer Sutherland Lou Diamond Phillips
32 Loose Cannons Link Gene Hackman Dan Aykroyd
33 Turner & Hooch Link Tom Hanks NA
34 Black Rain Link Michael Douglas Andy García
35 Tango & Cash Link Sylvester Stallone Kurt Russell
36 Downtown Link Anthony Edwards Forest Whitaker
37 I Come in Peace Link Dolph Lundgren Brian Benben
38 Marked for Death Link Joanna Pacula Keith David
39 The Rookie Link Clint Eastwood Charlie Sheen
40 Kindergarten Cop Link Arnold Schwarzenegger Penelope Ann Miller
41 The Hard Way Link Michael J. Fox James Woods
42 A Gnome Named Gnorm Link Anthony Michael Hall Jerry Orbach
43 Point Break Link Patrick Swayze Keanu Reeves
44 Showdown in Little Tokyo Link Dolph Lundgren Brandon Lee
45 The Last Boy Scout Link Bruce Willis Damon Wayans
46 Stop! Or My Mom Will Shoot Link Sylvester Stallone Estelle Getty
47 Last Action Hero Link Arnold Schwarzenegger F. Murray Abraham
48 Cop and a Half Link Burt Reynolds Ray Sharkey
49 Hellbound Link Chuck Norris Calvin Levels
50 Bad Boys Link Martin Lawrence Will Smith
52 Top Dog Link Chuck Norris NA
53 Seven Link Brad Pitt Morgan Freeman
54 Theodore Rex Link Whoopi Goldberg Armin Mueller-Stahl
55 The Rock Link Sean Connery Nicolas Cage
56 Bulletproof Link Damon Wayans Adam Sandler
57 Maximum Risk Link Jean-Claude Van Damme Natasha Henstridge
58 The Glimmer Man Link Steven Seagal Keenen Ivory Wayans
59 Metro Link Michael Wincott Donal Logue
60 Men in Black Link Tommy Lee Jones Will Smith
61 Rush Hour Link Jackie Chan Chris Tucker
62 The Negotiator Link Samuel L. Jackson Kevin Spacey
63 The Corruptor Link Chow Yun-fat Mark Wahlberg
64 Wild Wild West Link Will Smith Kevin Kline
65 The Bone Collector Link Denzel Washington Angelina Jolie
66 Blue Streak Link Martin Lawrence Luke Wilson
67 Shanghai Noon Link Jackie Chan Owen Wilson
68 Shanghai Knights Link Owen Wilson Donnie Yen
69 15 Minutes Link Robert De Niro Edward Burns
70 The Breed Link Adrian Paul Bokeem Woodbine
71 Osmosis Jones Link Chris Rock Laurence Fishburne
72 Replicant Link Jean-Claude Van Damme Michael Rooker
73 Training Day Link Denzel Washington Ethan Hawke
74 National Security Link Martin Lawrence Steve Zahn
75 Cradle 2 the Grave Link Jet Li DMX
76 Hollywood Homicide Link Harrison Ford Josh Hartnett
77 The Rundown Link The Rock Seann William Scott
78 Starsky & Hutch Link Ben Stiller Owen Wilson
79 White Chicks Link Jaime King Frankie Faison
80 Kiss Kiss Bang Bang Link Robert Downey, Jr. Val Kilmer
81 16 Blocks Link Bruce Willis Mos Def
82 Miami Vice Link Colin Farrell Jamie Foxx
83 The Pink Panther Link Kevin Kline Jean Reno
84 Righteous Kill Link Robert De Niro Al Pacino
85 Sherlock Holmes Link Robert Downey Jr. Jude Law
86 Cop Out Link Bruce Willis Tracy Morgan
87 The Grace Card Link Louis Gossett, Jr. Michael Jeffrey Joiner
88 The Other Guys Link Mark Wahlberg Will Ferrel
89 Big Mommas: Like Father, Like Son Link Martin Lawrence Brandon T. Jackson
90 Dredd Link Karl Urban Olivia Thirlby
91 End of Watch Link Jake Gyllenhaal Michael Peña
92 Bullet to the Head Link Sylvester Stallone Sung Kang
93 21 Jump Street Link Jonah Hill Channing Tatum
95 The Heat Link Sandra Bullock Melissa McCarthy
96 R.I.P.D. Link Jeff Bridges Ryan Reynolds
97 2 Guns Link Denzel Washington Mark Wahlberg
98 Ride Along Link Kevin Hart John Leguizamo
100 Let’s Be Cops Link Damon Wayans, Jr. Jake Johnson
101 Hot Pursuit Link Reese Witherspoon Sofía Vergara
102 Zootopia Link Ginnifer Goodwin Jason Bateman
103 Bastille Day Link Idris Elba Richard Madden
104 The Nice Guys Link Russell Crowe Ryan Gosling
105 Central Intelligence Link Dwayne Johnson Kevin Hart
106 Skiptrace Link Jackie Chan Jimmy Fallon

To be Continued

In another post the movie, buddies, or buddy interaction will be classified to look into the movies.