Reshaping data.frame from wide to long format in R
Last Updated : 22 Jul, 2025
Reshaping a data frame from wide to long format in R Programming Language is a common operation when dealing with data analysis and visualization. The process involves converting data that is spread across multiple columns (wide format) into a format where each row represents a single observation (long format).
Creating Sample Wide Data Frame
We create a wide-format data frame that stores test scores of students across multiple columns.
data.frame : creates a data frame by combining all the columns (like ID, Name, Test1, etc.)