knitr::opts_chunk$set( collapse = TRUE, warning = F, message = F, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(demdebates2020)
## basic example code debates <- readRDS("../dem_debates2/data/debates.RDS") # use_data(debates) m_chr <- c("Anderson Cooper", "Andrew Yang", "Bernie Sanders", "Beto O'Rourke", "Bill de Blasio", "Chuck Todd", "Cory Booker", "David Muir", "Don Lemon", "Eric Swalwell", "George Stephanopoulos", "Jake Tapper", "Jay Inslee", "Joe Biden", "John Delaney", "John Hickenlooper", "Jorge Ramos", "Joe Diaz-Balart", "Julian Castro", "Lester Holt", "Mark Lacey", "Michael Bennet", "Pete Buttigieg", "Steve Bullock", "Tim Alberta", "Tim Ryan", "Tom Steyer", "Wolf Blizer", "Jose Diaz-Balart") f_chr <- c("Amy Klobuchar", "Andrea Mitchell", "Ashley Parker", "Elizabeth Warren", "Judy Woodruff", "Kamala Harris", "Kirsten Gillibrand", "Kristen Welker", "Marianne Williamson", "Rachel Maddow", "Tulsi Gabbard", "Abby Phillip", "Amna Nawaz", "Brianne Pfannenstiel", "Dana Bash", "Erin Burnett", "Lindsey Davis", "Savannah Guthrie", "Yamiche Alcindor") debates <- debates %>% # mutate(speaker = lagged) %>% fill(type, .direction = "down") %>% fill(speaker, .direction = "down") %>% select(-lagged) %>% mutate_all(str_trim) %>% # mutate_all(~str_remove(.x, "<U\\+2009>") %>% str_trim) %>% mutate_all(~stringi::stri_trans_general(.x, "latin-ascii")) %>% mutate(speech = ifelse(!is.na(background), background, speech)) %>% filter(!str_count(speech)==0) %>% mutate(speech = ifelse(!is.na(background), NA, speech)) %>% mutate(day = case_when( debate == "1A" ~ 1, debate == "1B" ~ 2, debate == "2A" ~ 1, debate == "2B" ~ 2, T ~ 1 )) %>% mutate(debate = case_when( debate == "1A" ~ 1, debate == "1B" ~ 1, debate == "2A" ~ 2, debate == "2B" ~ 2, T ~ parse_number(debate) )) %>% mutate(gender = case_when( speaker %in% m_chr ~ "male", speaker %in% f_chr ~ "female", T ~ "unknown" )) %>% select(speaker ,background, speech, type, gender, debate, day ) %>% mutate(speaker = ifelse(speaker == "Protestor", "Protester", speaker)) debates <- readRDS("D:/Projects/git_proj/dem_debates2/data/debates9.RDS") debates <- readRDS("D:/Projects/git_proj/dem_debates2/data/debates10.RDS") debates <- readRDS("D:/Projects/git_proj/dem_debates2/data/debates11.RDS") use_data(debates, overwrite = T) debates %>% dplyr::filter(debate == 11)
The goal of demdebates2020
is to provide access to all transcripts of the Democratic debates of the 2020 Presidential Election.
The package includes a single dataset: debates
. This dataset represents the spoken words of all Democratic candidates for US president at eleven Democratic debates. The following sources have been used to compile the data: Washington Post, Des Moines Register and rev.com. The dataset has the following eight columns:
speaker
: Who is speakingbackground
: Reactions from the audience, includes (APPLAUSE)
or (LAUGHTER)
speech
: Transcribed speechtype
: Candidate, Moderator or Protestergender
: The gender of the person speakingdebate
: Which debate day
: Which day of the debate order
: The order in which the speech acts were deliveredThere are two ways in which you can access the dataset.
debates_url <- "https://raw.githubusercontent.com/favstats/demdebates2020/master/data/debates.csv" debates <- readr::read_csv(debates_url)
devtools::install_github("favstats/demdebates2020") library(demdebates2020)
demdebates2020::debates %>% dplyr::slice(1508:1510) %>% knitr::kable()
Check out this blog post for some more data exploration.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.