knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(csatimer) library(ggplot2) library(tidyverse)
csatimer
provides data on how much airtime French politician receive in the media.
The datasets contained in the package are also available in the csv-format.
# install.packages("devtools") devtools::install_github("benjaminguinaudeau/csatimer")
Last Update: February, 2nd 2022
Two types of datasets are provided:
Every month, the CSA collects how long each political personality speaks on each of the major radio and TV stations.
This dataset can be accessed using read_csa_routine
and is continuous between September 2017 and January 2022.
read_csa_routine() %>% glimpse
It contains the following columns:
"2017-01-01"
"TF1", "France 2", "France Inter", ...
"JT", "MAG", "PROG"
"Emmanuel Macron", "Marine Le Pen", "François Hollande", ...
"Président", "Parti Socialiste", "Ministre", "Les Républicains", ...
"Exécutif" , "Ps", "LR", ...
Speaking times are measured in minutes. For instance, in September 2017, Emanuel Macron spoke 8.4 minutes on TF1.
prog_type
refers to different types of TV/Radio shows:
JT
: newscastMAG
: political showsPROG
: non-political showsDuring electoral campaigns - presidential, legislative and local - , the CSA publishes airtime of campaigning candidates data every two weeks.
For each candidate, three different measures are computed:
time_candidat
: speaking time of the candidate themselvestime_support
: speaking time of personalities supporting the candidatetime_mention
: speaking time of journalists mentioning the candidateThis dataset can be accessed using read_csa_election("pres_2022")
.
Following elections are available:
read_csa_election("pres_2022")
read_csa_election("pres_2017")
read_csa_election("pres_2022") %>% dplyr::glimpse()
Data will be updated as the CSA publishes new routine and campaign data.
To update the data local version, use update_csatimer()
# Updating data update_csatimer()
Here are some graphic examples using csatimer::read_csa_routine()
read_csa_routine() %>% group_by(month) %>% summarise(n_hours = sum(time, na.rm = T)/60) %>% ggplot(aes(x = month, n_hours)) + geom_line() + theme_minimal() + labs(x = "", y = "Monthly number of hours of political attention", title = "How much do politicians speak in the media?")
read_csa_routine() %>% add_station_dummies %>% mutate(private = ifelse(is_private, "Private", "Public")) %>% group_by(private, station, month) %>% summarise(n_hours = sum(time, na.rm = T)/60) %>% ungroup %>% mutate(station = fct_reorder(station, n_hours)) %>% ggplot(aes(x = station, n_hours, fill = private)) + geom_boxplot(outlier.alpha = 0) + coord_flip() + labs(x = "Media outlet", y = "\nMonthly number of hours of political attention", fill = "") + theme_minimal()
read_csa_routine() %>% group_by(party, name) %>% summarise(n_hours = sum(time, na.rm = T)/60) %>% ungroup %>% slice_max(n_hours, n = 20) %>% mutate(name = fct_reorder(name, n_hours)) %>% ggplot(aes(x = name, y = n_hours, fill = party)) + geom_col() + coord_flip() + theme_minimal() + labs(x = "Politicians", y = "Total Number of hours")
read_csa_routine() %>% filter(month > lubridate::dmy("07-01-2021")) %>% filter(station %in% c("TF1", "France 2", "France 3", "C8")) %>% group_by(station, party, name) %>% summarise(n_hours = sum(time, na.rm = T)/60) %>% ungroup %>% group_by(station) %>% slice_max(n_hours, n = 20) %>% ungroup %>% mutate(name = fct_reorder(name, n_hours)) %>% ggplot(aes(x = name, y = n_hours, fill = party)) + geom_col() + coord_flip() + theme_minimal() + facet_wrap(~station, scales = "free") + labs(x = "Politicians", y = "Total Number of hours") + ggtitle("Which politicians obtained the highest attention on four channel since July 2022?")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.