0Pricing
R Academy · Lesson

Tidying Data with tidyr

Transform messy data into a tidy format to facilitate analysis using tidyr functions.

1

Introduction to Tidying Data with tidyr

The tidyr package helps in organizing messy data into a structured format.

Tidying Data with tidyr — illustration 1

2

Pivoting Data: Wide to Long

Use pivot_longer() to convert wide format data to long format.

library(tidyr)
data <- data.frame(Name = c('Alice', 'Bob'), Jan = c(10, 15), Feb = c(20, 25))
data_long <- pivot_longer(data, cols = c('Jan', 'Feb'), names_to = 'Month', values_to = 'Score')

All lessons in this course

  1. Introduction to Tidyverse
  2. Data Wrangling with dplyr
  3. Tidying Data with tidyr
← Back to R Academy