</>
Skip to content
R lessons (41/41)

R — tidyr

pivot_longer

library(tidyr)
data %>% pivot_longer(cols = c(a, b, c), names_to = "var", values_to = "val")

pivot_wider

data %>% pivot_wider(names_from = var, values_from = val)

separate

data %>% separate(col, into = c("c1", "c2"), sep = ",")

Mini Practice

  1. Reshape longer
  2. Reshape wider
  3. Separate columns
  4. Unite columns

Up Next

Continue with Statistics - Statistical functions.

Related Topics

Frequently Asked Questions about tidyr

What is tidyr in R?

tidyr is a fundamental concept in R. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn tidyr?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn tidyr.

Why is tidyr important in R?

tidyr is essential for R development. Understanding this concept will help you write better code and solve real-world problems more effectively.