Data 2

Session 4

François Briatte
(small modifs by Kim Antunez & ChatGPT)

2024-02-27

Continue to wrangle

Exercises

Exercise 1

Source: https://www.cambridge.org

Source: https://www.cambridge.org

The article “Measuring Public Support for European Integration across Time and Countries: The ‘European Mood’ Indicator” by Isabelle Guinaudeau and Tinette Schnatterer addresses the challenge of measuring public support for the European Union (EU), in the context of increasing contestation of European integration. They emphasize the need for a consistent and comparable instrument to measure citizens’ preferences and to analyze the dynamic relationship between public opinion, party politics, and policy making.

Exercise 2

Source: https://search.gesis.org/research_data/ZA7581

Source: https://search.gesis.org/research_data/ZA7581

In this article, Hermann Schmitt, Sara B. Hobolt, and Wouter van der Brug describe the results of a post-election study, conducted in all 28 EU member states after the elections to the European Parliament were held between 23 and 26 May 2019. The main objective of the 2019 EES Voter study is to study electoral participation and voting behaviour in European Parliament elections.

In particular, question 10 ask how probable is it that people will ever vote for different parties in their country.

Source: https://www.europeanelectionstudies.net

Source: https://www.europeanelectionstudies.net

More on Tidying data

Reshaping (pivoting)

Reshaping involves restructuring data to transform it from a wide format to a long format or vice versa.

Source: https://r4ds.had.co.nz

Source: https://r4ds.had.co.nz

Splitting (separating)

Splitting involves breaking a dataset into smaller groups based on a specified variable, allowing for separate analysis and manipulation of each group’s data.

Source: https://r4ds.had.co.nz

Source: https://r4ds.had.co.nz

Merging (joining)

Source: https://r4ds.had.co.nz

Source: https://r4ds.had.co.nz

Merging involves combining multiple datasets based on shared variables to create a single unified dataset:

  • Left Join: Includes all records from the left dataset and matching records from the right dataset.
  • Right Join: Includes all records from the right dataset and matching records from the left dataset.
  • Inner Join: Includes only matching records from both datasets.
  • Full Join: Includes all records from both datasets, filling in with NA where there are no matches.

Source: https://r4ds.had.co.nz

Source: https://r4ds.had.co.nz

More Cheatsheets

Source : https://raw.githubusercontent.com/rstudio

Source : https://raw.githubusercontent.com/rstudio

Source : https://raw.githubusercontent.com/rstudio

Source : https://raw.githubusercontent.com/rstudio

Exam 1

  • Instructions here
    • in group & graded
    • real-world dataset (road traffic accidents in France)
    • data cleaning and data analysis tasks
    • Submit a script called exam1_solution.R (Subject : “DSR Exam 1 Submission”, To : )
    • Deadline : mar. 12th, before 7:15 pm.
    • Make sure your script is well-organized

Homework for next week

Bonus : databases

Databases serve as organized repositories of data structured into tables with defined relationships:

  • They employ common ‘id’ columns to establish connections between different tables
  • Optimised for speed with large data tables/streams
  • Requires learning a DB query language

Two main approaches are available for managing data within databases:

  • Standard, SQL : predominantly row-oriented and comes in various versions to suit different database systems.
  • Alternatively, MonetDB : employs a column-oriented structure

The dbplyr package acts as a connector that extends the capabilities of dplyr. It relies on ODBC/DBI drivers, which enable R to connect and communicate with a diverse array of database management systems:

  • MySQL
  • PostgreSQL
  • SQLite
  • Microsoft SQL Server
  • Oracle

There are also specialized drivers available for MonetDB such as:

  • MonetDB.R
  • MonetDBLite

But also :

  • bigrquery R package for Google BigQuery, a cloud-based data warehousing solution.

You can refer to Chapter 22 (ʻDatabasesʼ) in the book “R for Data Science” by Grolemund and Wickham or here.