diff --git a/DESCRIPTION b/DESCRIPTION index 2bc62a4..c85444d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: ggchicklet Type: Package Title: Create 'Chicklet' (Rounded Segmented Column) Charts -Version: 0.3.0 -Date: 2019-12-20 +Version: 0.4.0 +Date: 2020-01-14 Authors@R: c( person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5670-2640")), person("Antoine", "Bichat", role = "ctb") ) diff --git a/NEWS.md b/NEWS.md index 9b4679b..46f0412 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,2 +1,5 @@ +0.4.0 +* Data updated for latest debate + 0.1.0 * Initial release diff --git a/README.md b/README.md index 5477a4d..190f21a 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ library(ggchicklet) # current version packageVersion("ggchicklet") -## [1] '0.2.0' +## [1] '0.4.0' ``` ### From the NYTimes @@ -118,9 +118,9 @@ debates2019 %>% | Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | | :--- | -------: | ---: | ---: | ---: | ----------: | ---: | -------: | ---: | -| HTML | 8 | 0.44 | 8679 | 0.93 | 2364 | 0.97 | 350 | 0.63 | -| R | 8 | 0.44 | 513 | 0.06 | 38 | 0.02 | 122 | 0.22 | -| Rmd | 2 | 0.11 | 117 | 0.01 | 45 | 0.02 | 85 | 0.15 | +| HTML | 9 | 0.47 | 9049 | 0.93 | 2564 | 0.97 | 387 | 0.65 | +| R | 8 | 0.42 | 575 | 0.06 | 38 | 0.01 | 122 | 0.21 | +| Rmd | 2 | 0.11 | 117 | 0.01 | 45 | 0.02 | 85 | 0.14 | ## Code of Conduct diff --git a/data-raw/2020-01-14-us-elections-debate-speaking-time.html b/data-raw/2020-01-14-us-elections-debate-speaking-time.html new file mode 100644 index 0000000..d64fff9 --- /dev/null +++ b/data-raw/2020-01-14-us-elections-debate-speaking-time.html @@ -0,0 +1,607 @@ + + + + Which Candidates Got the Most Speaking Time in the Democratic Debate - The New York Times + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Advertisement

Which Candidates Got the Most Speaking Time in the Democratic Debate

+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + +

+ + How Long Each Candidate Spoke + + + + +

+ + + + + + +
+ + + + + + +
+ +

Military

+
+ +
+ +

Foreign policy

+
+ +
+ +

Trade

+
+ +
+ +

Can a woman win?

+
+ +
+ +

Health care

+
+ +
+ +

Child care

+
+ +
+ +

Education

+
+ +
+ +

Impeachment

+
+ +
+ +

Climate change

+
+ +
+ +

Electability

+
+ + + + +
+ + + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + Note: Each bar segment represents the length of a candidate’s response to a question. +
+ + +
+ +

+ Senators Elizabeth Warren and Bernie Sanders had the most speaking time of the six presidential candidates in the January Democratic debate. +

+

+ The debate started with a lengthy discussion on military and foreign policy in the wake of an American drone strike that killed Iran’s top military commander. Former Vice President Joseph R. Biden Jr. said his vote in 2002 to authorize the war in Iraq was a mistake. +

+

+ Democrats debated the merits of a new trade deal with Canada and Mexico. Mr. Sanders said he wouldn’t vote for the deal because it doesn’t address climate change, a move backed by Tom Steyer, who said climate is his “number one priority.” Senator Amy Klobuchar, Pete Buttigieg and Ms. Warren said they supported the new deal, which came together after negotiations between President Trump and House Democrats. +

+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + Note: The size of each circle represents the total length of a candidate’s responses to a topic. +
+ + +
+ +

+ The candidates again divided into two distinct camps on health care: Mr. Sanders and Ms. Warren said they support a “Medicare for all” approach, while Mr. Biden, Mr. Buttigieg and Ms. Klobuchar criticized the cost of such a plan, instead favoring a “public option.” +

+

+ Mr. Sanders denied that he told Ms. Warren in 2018 that a woman could not win the presidency. “Of course a woman can win the presidency,” he said. All the candidates agreed. +

+

+ Get full coverage of the Democratic presidential debate from the Times. +

+ +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ +
+ + + + \ No newline at end of file diff --git a/data-raw/debates2019.R b/data-raw/debates2019.R index fff5bca..67573c4 100644 --- a/data-raw/debates2019.R +++ b/data-raw/debates2019.R @@ -24,6 +24,7 @@ if (!file.exists(here::here("data-raw/2019-09-12-us-elections-debate-speaking-ti if (!file.exists(here::here("data-raw/2019-10-15-us-elections-debate-speaking-time.html"))) download.file("https://www.nytimes.com/interactive/2019/10/15/us/elections/debate-speaking-time.html", here::here("data-raw/2019-10-15-us-elections-debate-speaking-time.html")) if (!file.exists(here::here("data-raw/2019-11-20-us-elections-debate-speaking-time.html"))) download.file("https://www.nytimes.com/interactive/2019/11/20/us/elections/debate-speaking-time.html", here::here("data-raw/2019-11-20-us-elections-debate-speaking-time.html")) if (!file.exists(here::here("data-raw/2019-12-19-us-elections-debate-speaking-time.html"))) download.file("https://www.nytimes.com/interactive/2019/12/19/us/elections/debate-speaking-time.html", here::here("data-raw/2019-12-19-us-elections-debate-speaking-time.html")) +if (!file.exists(here::here("data-raw/2020-01-14-us-elections-debate-speaking-time.html"))) download.file("https://www.nytimes.com/interactive/2020/01/14/us/politics/debate-speaking-time.html", here::here("data-raw/2020-01-14-us-elections-debate-speaking-time.html")) read_html(here::here("data-raw/2019-06-26-us-elections-debate-speaking-time.html")) %>% html_nodes(xpath = ".//script[contains(., 'NYTG_DEMDEBATES')]") %>% @@ -354,7 +355,6 @@ read_html(here::here("data-raw/2019-11-20-us-elections-debate-speaking-time.html ) %>% as_tibble() -> nov_day_1 - read_html(here::here("data-raw/2019-12-19-us-elections-debate-speaking-time.html")) %>% html_nodes(xpath = ".//script[contains(., 'NYTG_DEMDEBATES')]") %>% html_text() %>% @@ -412,6 +412,67 @@ read_html(here::here("data-raw/2019-12-19-us-elections-debate-speaking-time.html ) %>% as_tibble() -> dec_day_1 +read_html(here::here("data-raw/2020-01-14-us-elections-debate-speaking-time.html")) %>% + html_nodes(xpath = ".//script[contains(., 'NYTG_DEMDEBATES')]") %>% + html_text() %>% + stri_split_lines() %>% + unlist() %>% + .[3] %>% + stri_replace_first_regex("^.*NYTG_DEMDEBATES = ", "") %>% + jsonlite::fromJSON() %>% + as_tibble() %>% + mutate( + elapsed = as.numeric(elapsed)/60, + debate_date = as.Date("2020-01-14"), + speaker = stri_trans_totitle(speaker), + timestamp = parse_time(timestamp), + debate_group = 7, + night = 1 + ) %>% + filter(speaker != "") %>% + mutate( + topic = case_when( + topic == "" ~ "Other", + grepl("military", topic) ~ "Military", + grepl("climate", topic) ~ "Climate", + grepl("closing", topic) ~ "Closing", + grepl("judges", topic) ~ "Judges", + grepl("race", topic) ~ "Race", + grepl("education", topic) ~ "Education", + grepl("human-rights", topic) ~ "Human Rights", + grepl("criminal-justice", topic) ~ "Criminal Justice", + grepl("electability", topic) ~ "Electability", + grepl("election-reform", topic) ~ "Election Reform", + grepl("executive-power", topic) ~ "Executive Power", + grepl("candidate-age", topic) ~ "Age", + grepl("foreign-policy", topic) ~ "Foreign Policy", + grepl("gun-control", topic) ~ "Gun Control", + grepl("child-care", topic) ~ "Child Care", + grepl("health-care", topic) ~ "Healthcare", + grepl("immigration", topic) ~ "Immigration", + grepl("impeachment", topic) ~ "Impeachment", + grepl("income-inequality", topic) ~ "Income Inequality", + grepl("female-president", topic) ~ "Female President", + grepl("trade", topic) ~ "Trade", + grepl("economy", topic) ~ "Economy", + grepl("middle-east policy", topic) ~ "Foreign Policy", + grepl("opioids", topic) ~ "Opioids", + grepl("party-strategy", topic) ~ "Party Strategy", + grepl("public-service", topic) ~ "Public Service", + grepl("tech-companies", topic) ~ "Tech Companies", + grepl("white-supremacist violence", topic) ~ "White-Supremacy", + grepl("womens-issues", topic) ~ "Women's Rights", + topic == "" ~ "Other", + TRUE ~ topic + ) + ) %>% + filter( + !is.na(timestamp), + speaker != "", + speaker != "Moderator" + ) %>% + as_tibble() -> jan_20_day_1 + bind_rows( jun_day_1, jun_day_2, @@ -420,7 +481,8 @@ bind_rows( sep_day_1, oct_day_1, nov_day_1, - dec_day_1 + dec_day_1, + jan_20_day_1 ) %>% mutate(topic = case_when( grepl("elect.*form", topic, ignore.case = TRUE) ~ "Election Reform", diff --git a/data/debates2019.rda b/data/debates2019.rda index 7347a0b..2beb4ce 100644 Binary files a/data/debates2019.rda and b/data/debates2019.rda differ