Intermediate R

In this session , we will learn about function and control structures such as writing functions , if statements, and loops.

We will also explore Data Cleaning and Transformations such as handling missing data , reshaping data using the dplyr functions.

First , we need to load this package

#install.packages("tidyverse")
library(tidyverse)
#> ── Attaching core tidyverse packages ──── tidyverse 2.0.0 ──
#> ✔ dplyr     1.1.4     ✔ readr     2.1.4
#> ✔ forcats   1.0.0     ✔ stringr   1.5.1
#> ✔ ggplot2   3.5.0     ✔ tibble    3.2.1
#> ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
#> ✔ purrr     1.0.2     
#> ── Conflicts ────────────────────── tidyverse_conflicts() ──
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::lag()    masks stats::lag()
#> ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

It will load

  1. ggplot2: Used for data visualization using the grammar of graphics.
  2. dplyr: Provides a set of tools for efficiently manipulating datasets.
  3. tidyr: Used for tidying data, that is, transforming it to a format that is easy to work with.
  4. readr: Used to read rectangular data like CSVs and text files into R.
  5. purrr: Enhances R’s functional programming (FP) toolkit, making it easier to work with lists and functions.
  6. tibble: A modern reimagining of data frames, providing a cleaner and more user-friendly data structure.
  7. stringr: Simplifies the process of working with strings (text data).
  8. forcats: Designed to handle categorical variables (factors) with ease.

In this session , we will use some of them