knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

library(csatimer)
library(ggplot2)
library(tidyverse)

csatimer

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.

Installation

# install.packages("devtools")
devtools::install_github("benjaminguinaudeau/csatimer")

Data

Last Update: February, 2nd 2022

Two types of datasets are provided:

Routine period (no electoral campaigns)

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:

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:

Electoral campaigns

During 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:

This dataset can be accessed using read_csa_election("pres_2022").

Following elections are available:

read_csa_election("pres_2022")  %>%
  dplyr::glimpse()

Updating data

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()

Example {.tabset}

Here are some graphic examples using csatimer::read_csa_routine()

Example 1

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?")

Example 2

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() 

Example 3

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")

Example 4

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?")


benjaminguinaudeau/csatimer documentation built on April 4, 2022, 1:51 p.m.