diff --git a/DESCRIPTION b/DESCRIPTION index 4cffbe8..2117a11 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: ggchicklet Type: Package Title: Create 'Chicklet' (Rounded Segmented Column) Charts -Version: 0.5.0 -Date: 2020-02-07 +Version: 0.5.2 +Date: 2020-02-25 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") ) @@ -10,8 +10,8 @@ Maintainer: Bob Rudis Description: Sometimes it is useful to stylize column charts a bit more than just bland rectangles. Methods are provided to create rounded rectangle segmented column charts (i.e. 'chicklets'). -URL: https://gitlab.com/hrbrmstr/ggchicklet -BugReports: https://gitlab.com/hrbrmstr/ggchicklet/issues +URL: https://git.rud.is/hrbrmstr/ggchicklet +BugReports: https://git.rud.is/hrbrmstr/ggchicklet/issues Encoding: UTF-8 License: MIT + file LICENSE Suggests: covr, hrbrthemes, dplyr, forcats, knitr, rmarkdown, diff --git a/NEWS.md b/NEWS.md index 49dff4d..692bd05 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +0.5.2 +* Data updated for latest debate (2020-02-25) + 0.5.1 * Data updated for latest debate (2020-02-19) diff --git a/README.md b/README.md index d3f39f5..69811a8 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ library(ggchicklet) # current version packageVersion("ggchicklet") -## [1] '0.5.0' +## [1] '0.5.2' ``` ### From the NYTimes @@ -116,11 +116,11 @@ debates2019 %>% ## ggchicklet Metrics -| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | -| :--- | -------: | --: | ---: | ---: | ----------: | ---: | -------: | ---: | -| HTML | 10 | 0.5 | 9426 | 0.93 | 2765 | 0.97 | 425 | 0.67 | -| R | 8 | 0.4 | 642 | 0.06 | 40 | 0.01 | 122 | 0.19 | -| Rmd | 2 | 0.1 | 117 | 0.01 | 45 | 0.02 | 85 | 0.13 | +| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | +| :--- | -------: | ---: | ----: | ---: | ----------: | ---: | -------: | ---: | +| HTML | 12 | 0.55 | 10200 | 0.92 | 3169 | 0.97 | 501 | 0.71 | +| R | 8 | 0.36 | 788 | 0.07 | 45 | 0.01 | 122 | 0.17 | +| Rmd | 2 | 0.09 | 117 | 0.01 | 45 | 0.01 | 85 | 0.12 | ## Code of Conduct diff --git a/data-raw/2020-02-25-us-elections-debate-speaking-time.html b/data-raw/2020-02-25-us-elections-debate-speaking-time.html new file mode 100644 index 0000000..1f46d0c --- /dev/null +++ b/data-raw/2020-02-25-us-elections-debate-speaking-time.html @@ -0,0 +1,635 @@ + + + + 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 + + + + +

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

Electability

+
+ +
+ +

Health care

+
+ +
+ +

Racial justice

+
+ +
+ +

Sexism

+
+ +
+ +

Gun control

+
+ +
+ +

Economy

+
+ +
+ +

Education

+
+ +
+ +

Criminal justice

+
+ +
+ +

Coronavirus

+
+ +
+ +

Foreign policy

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

+ Senator Bernie Sanders of Vermont, former mayor Michael R. Bloomberg of New York and Senator Amy Klobuchar of Minnesota had the most speaking time of the seven Democratic presidential candidates in the debate in Charleston, S.C., ahead of the South Carolina primary on Saturday. +

+

+ Electability, foreign policy, gun control and racial justice were major topics during the debate. The candidates also sparred over Russian election interference, housing discrimination and each other’s legislative record. +

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

+ Like last week’s debate, the night was more heated than usual. Mr. Bloomberg continued to come under fire for his billionaire status and treatment of women, and Mr. Sanders’s newfound position as clear front-runner made him a target as well. Almost every candidate criticized Mr. Sanders in the first 10 minutes of the debate, challenging his electability, health care plan and record on gun control. +

+

+ The night took a turn toward the chaotic when, after Ms. Klobuchar challenged the math of Mr. Sanders’s “Medicare for all” plan, there was more than half a minute of sustained crosstalk among the candidates as they tried to interrupt to make their points. +

+

+ The increasing threat of the spread of the coronavirus became a topic of debate for the first time, with candidates criticizing the Trump administration’s preparations for an outbreak and Mr. Biden referring to the Obama administration’s efforts to combat the Ebola virus. +

+

+ 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 dd81d54..a0a77d3 100644 --- a/data-raw/debates2019.R +++ b/data-raw/debates2019.R @@ -27,6 +27,7 @@ if (!file.exists(here::here("data-raw/2019-12-19-us-elections-debate-speaking-ti 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")) if (!file.exists(here::here("data-raw/2020-02-07-us-elections-debate-speaking-time.html"))) download.file("https://www.nytimes.com/interactive/2020/02/07/us/elections/debate-speaking-time.html", here::here("data-raw/2020-02-07-us-elections-debate-speaking-time.html")) if (!file.exists(here::here("data-raw/2020-02-19-us-elections-debate-speaking-time.html"))) download.file("https://www.nytimes.com/interactive/2020/02/19/us/elections/debate-speaking-time.html", here::here("data-raw/2020-02-19-us-elections-debate-speaking-time.html")) +if (!file.exists(here::here("data-raw/2020-02-25-us-elections-debate-speaking-time.html"))) download.file("https://www.nytimes.com/interactive/2020/02/25/us/elections/debate-speaking-time.html", here::here("data-raw/2020-02-25-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')]") %>% @@ -490,7 +491,7 @@ read_html(here::here("data-raw/2020-02-07-us-elections-debate-speaking-time.html as_tibble() %>% mutate( elapsed = as.numeric(elapsed)/60, - debate_date = as.Date("2020-01-14"), + debate_date = as.Date("2020-02-07"), speaker = stri_trans_totitle(speaker), timestamp = parse_time(timestamp), debate_group = 8, @@ -557,7 +558,7 @@ read_html(here::here("data-raw/2020-02-19-us-elections-debate-speaking-time.html as_tibble() %>% mutate( elapsed = as.numeric(elapsed)/60, - debate_date = as.Date("2020-01-14"), + debate_date = as.Date("2020-02-19"), speaker = stri_trans_totitle(speaker), timestamp = parse_time(timestamp), debate_group = 9, @@ -565,8 +566,6 @@ read_html(here::here("data-raw/2020-02-19-us-elections-debate-speaking-time.html ) %>% filter(speaker != "") %>% filter(!is.na(timestamp)) %>% - # distinct(topic) %>% - # print(n=nrow(.)) mutate( topic = case_when( topic == "" ~ "Other", @@ -618,6 +617,78 @@ read_html(here::here("data-raw/2020-02-19-us-elections-debate-speaking-time.html as_tibble() -> feb_19_day_1 +read_html(here::here("data-raw/2020-02-25-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-02-25"), + speaker = stri_trans_totitle(speaker), + timestamp = parse_time(timestamp), + debate_group = 10, + night = 1 + ) %>% + filter(speaker != "") %>% + filter(!is.na(timestamp)) %>% + mutate( + topic = case_when( + topic == "" ~ "Other", + grepl("coronavirus", topic) ~ "Coronavirus", + grepl("military", topic) ~ "Military", + grepl("climate", topic) ~ "Climate", + grepl("closing", topic) ~ "Closing", + grepl("judges", topic) ~ "Judges", + grepl("race", topic) ~ "Race", + grepl("Climate-change", topic) ~ "Climate", + grepl("poverty", topic) ~ "Poverty", + grepl("education", topic) ~ "Education", + grepl("bloomberg", topic) ~ "Bloomberg", + grepl("human-rights", topic) ~ "Human Rights", + grepl("criminal-justice", topic) ~ "Criminal Justice", + grepl("racial-justice", topic) ~ "Racial Justice", + grepl("electability", topic) ~ "Electability", + grepl("election-reform", topic) ~ "Election Reform", + grepl("executive-power", topic) ~ "Executive Power", + grepl("candidate-age", topic) ~ "Age", + grepl("supreme-court", topic) ~ "Supreme Court", + grepl("foreign-policy", topic) ~ "Foreign Policy", + grepl("gun-control", topic) ~ "Gun Control", + grepl("child-care", topic) ~ "Child Care", + grepl("party-loyalty", topic) ~ "Party Loyalty", + grepl("health-care", topic) ~ "Healthcare", + grepl("immigration", topic) ~ "Immigration", + grepl("impeachment", topic) ~ "Impeachment", + grepl("economic-inequality", topic) ~ "Income Inequality", + grepl("income-inequality", topic) ~ "Income Inequality", + grepl("female-president", topic) ~ "Female President", + grepl("trade", topic) ~ "Trade", + grepl("economy", topic) ~ "Economy", + grepl("sexism", topic) ~ "Sexism", + 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() -> feb_25_day_1 + + bind_rows( jun_day_1, jun_day_2, @@ -629,10 +700,12 @@ bind_rows( dec_day_1, jan_20_day_1, feb_07_day_1, - feb_19_day_1 + feb_19_day_1, + feb_25_day_1 ) %>% mutate(topic = case_when( grepl("elect.*form", topic, ignore.case = TRUE) ~ "Election Reform", + grepl("transparency", topic, ignore.case = TRUE) ~ "Transparency", TRUE ~ topic )) -> debates2019 diff --git a/data/debates2019.rda b/data/debates2019.rda index fa32c52..a01de41 100644 Binary files a/data/debates2019.rda and b/data/debates2019.rda differ diff --git a/man/ggchicklet.Rd b/man/ggchicklet.Rd index 9b6bc26..b91e8d7 100644 --- a/man/ggchicklet.Rd +++ b/man/ggchicklet.Rd @@ -26,8 +26,8 @@ A sample of the output from \code{geom_chicklet()}: \seealso{ Useful links: \itemize{ - \item \url{https://gitlab.com/hrbrmstr/ggchicklet} - \item Report bugs at \url{https://gitlab.com/hrbrmstr/ggchicklet/issues} + \item \url{https://git.rud.is/hrbrmstr/ggchicklet} + \item Report bugs at \url{https://git.rud.is/hrbrmstr/ggchicklet/issues} } }