Logo

Basics of R for Data Science

PhD Course in Psychological Sciences - University of Padova

Author

Enrico Toffalini

About This Course

This is a short (10 hours) introductory course on R that is offered within the PhD program in Psychological Sciences (University of Padova). The course is aimed to prepare students for many future methodological courses in this program, where R is used extensively. R is a high-level open-source programming language that is widely used in academic research, but also increasingly adopted in business for data science. It has a large ecosystem of libraries and tools that allow you to perform flexible and powerful data analysis. RStudio is a popular IDE (Integrated Development Environment) which provides an excellent environment for coding, visualization, and report generation when programming in R (and in other languages).

The primary resource for the course is the online book available on GitHub: Introduction2R

Dates and Rooms

Day Time Room
Monday, 10th November 2025 10:30-12:30 4M
Tuesday, 11th November 2025 9:30-12:30 4M
Wednesday, 12th November 2025 9:30-12:30 4M
Thursday, 13th November 2025 8:30-10:30 4M

Getting Started

  1. Bookmark this course homepage to have quick access to this material (https://enricotoffalini.github.io/Basics-R/).
  2. Install R: go to the official R download page and follow the installation instructions for your operating system (further setup instructions can be found in Chapter 1 of Introduction2R).
  3. Install RStudio as the IDE (Integrated Development Environment): go to the RStudio Desktop download page to install the IDE on your computer. (If you don’t like RStudio or want to try alternative environments, have a look at Positron, or Jupyter notebook or even Google Colab setting R kernel for fully online coding).
  4. Test your local setup: Make sure that you local R installation works. Open RStudio and run the following code in the console panel:
pkgs = c("readxl", "psych", "ggplot2")
install.packages(pkgs)

psych::fisherz(0.5)
rnorm(10)

Course Topics

The goal of this short course is to make you proficient with the development environment, basic data structures, and essential concepts of programming in R. Advanced topics like statistical modelling and data simulation will be covered in future courses and are not presented here, although occasional simple examples may appear

Introduction to the R Environment and First Steps in R

Install R, manage work sessions in R Studio, create objects, understand data types and perform basic operations on them, import and export data, figures, and workspaces

Data Structures

Understand main data structures in R and interact with them effectively: vectors, matrices, dataframes, factors, lists. Manipulating data with dataframes will be given special attention

Basics of Programming in R

Understand essential programming concepts and their implementation in R: write conditional operations (e.g., if...else), run iterative programming (for and other loops; *apply family), define custom functions

A bit more

Some materials in the Exercises section below will provide more stimulating challenges even beyond the scope of the present introductory course, depending on the interest and the prior experience with R

Materials

Slides

Extra materials

Have a look at these pages, and remember that they are here if you need them later:

Exercises

— The following exercises are fundamental, and they importantly integrate concepts from the slides and introduce new functions and methods that you want to know!

— These other exercises are beyond the scope of this introductory course, but they could be stimulating and useful for more advanced R users:


GitHub repository associated to the present course website: https://github.com/EnricoToffalini/Basics-R

Access padlet

Thousands of thanks to Filippo Gambarota for sharing his expertise in using GitHub and Quarto.