Libraries
library(tidyverse)
## ── Attaching packages ───────────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.1.0 ✔ purrr 0.2.5
## ✔ tibble 2.1.1 ✔ dplyr 0.8.0.1
## ✔ tidyr 0.8.2 ✔ stringr 1.3.1
## ✔ readr 1.1.1 ✔ forcats 0.3.0
## ── Conflicts ──────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
#Thinking about online news, I am concerned about what is real and what is fake on the internet.
real_fake <- read_csv("data/misinfo/concern-real-vs-fake-seg.csv")
## Parsed with column specification:
## cols(
## segment = col_character(),
## `Not at all concerned` = col_double(),
## `Not very concerned` = col_double(),
## `Somewhat concerned` = col_double(),
## `Very concerned` = col_double(),
## `Extremely concerned` = col_double(),
## total_concerned = col_double(),
## total_not_concerned = col_double()
## )
# don't use column name as key or value in `gather()`!!!
stack_real_fake <- real_fake %>% select(segment, `Not at all concerned`, `Not very concerned`, `Somewhat concerned`, `Very concerned`, `Extremely concerned`) %>% gather(concern, percent, `Not at all concerned`, `Not very concerned`, `Somewhat concerned`, `Very concerned`, `Extremely concerned`)
stack_real_fake <- stack_real_fake %>% mutate(percent_new = percent * 100)
#To what extent, if at all, are you concerned about the following: - Poor journalism (factual mistakes, dumbed down stories, misleading headlines/clickbait)
poor_J <- read_csv("data/misinfo/poor-journalism-agreement-seg.csv")
## Parsed with column specification:
## cols(
## segment = col_character(),
## `Strongly disagree` = col_double(),
## `Tend to disagree` = col_double(),
## `Neither agree nor disagree` = col_double(),
## `Tend to agree` = col_double(),
## `Strongly agree` = col_double(),
## total_agree = col_double(),
## total_disagree = col_double()
## )
stack_poor_J <- poor_J %>% select(segment, `Strongly disagree`, `Tend to disagree`, `Neither agree nor disagree`, `Tend to agree`, `Strongly agree`) %>% gather(agreement, percent, `Strongly disagree`, `Tend to disagree`, `Neither agree nor disagree`, `Tend to agree`, `Strongly agree`)
stack_poor_J <- stack_poor_J %>% mutate(percent_new = percent * 100)
fake_theme <- function(){
list(
theme_minimal(),
scale_fill_manual(values=c('#253494', '#ffffcc','#a1dab4','#41b6c4','#2c7fb8'),
name="Level of Concern",
breaks=c("Not at all concerned", "Not very concerned", "Somewhat concerned", "Very concerned", "Extremely concerned"),
labels=c("Not at all concerned", "Not very concerned", "Somewhat concerned", "Very concerned", "Extremely concerned"))
)
}
poorJ_theme <- function(){
list(
theme_minimal(),
scale_fill_manual(values=c('#2c7fb8', '#253494', '#ffffcc','#a1dab4','#41b6c4'),
name="Level of Agreement",
breaks=c("Strongly disagree", "Tend to disagree", "Neither agree nor disagree", "Tend to agree", "Strongly agree"),
labels=c("Strongly disagree", "Tend to disagree", "Neither agree nor disagree", "Tend to agree", "Strongly agree"))
)
}
fake_plot <- ggplot(stack_real_fake, aes(segment, percent_new, width=.6)) +
geom_bar(aes(fill = concern), stat = "identity", position = "dodge") +
fake_theme() +
coord_flip() +
labs(title = "I am concerned about what is real and what is fake on the internet:", x = "Segment", y = "Percent", caption = "Source: Reuters 2018 Digital News Report")
fake_plot
poorJ_plot <- ggplot(stack_poor_J, aes(segment, percent_new, width=.6)) +
geom_bar(aes(fill = agreement), stat = "identity", position = "dodge") +
poorJ_theme() +
coord_flip() +
labs(title = "Concerned about Poor journalism\n(factual mistakes, dumbed down stories, misleading headlines/clickbait):", x = "Segment", y = "Percent", caption = "Source: Reuters 2018 Digital News Report")
poorJ_plot
export:
# PDF or PNG
# to speficiy a chart add a "plot = plot_name" parameter after the file name.
ggsave("real-v-fake.pdf", plot = fake_plot, width = 8, height = 8, units = "in", dpi = 320)
ggsave("real-v-fake.png", plot = fake_plot, width = 8, height = 8, units = "in", dpi = 320)
ggsave("poor_journalism.pdf", plot = poorJ_plot, width = 11, height = 8, units = "in", dpi = 320)
ggsave("poor_journalism.png", plot = poorJ_plot, width = 11, height = 8, units = "in", dpi = 320)