Tidyr

R

R tidyr - pivot_wider() (Long to Wide)

Long-format data stores observations in rows where each row represents a single measurement. Wide-format data spreads these measurements across columns. pivot_wider() from the tidyr package…

Read more →
R

R tidyr - unite() Columns into One

The unite() function from the tidyr package merges multiple columns into one. The basic syntax requires the data frame, the name of the new column, and the columns to combine.

Read more →
R

R tidyr - expand_grid() and crossing()

Both expand_grid() and crossing() create data frames containing all possible combinations of their input vectors. They’re essential for generating test scenarios, creating complete datasets for…

Read more →
R

R tidyr - fill() - Fill Missing Values

The fill() function from tidyr addresses a common data cleaning challenge: missing values that should logically carry forward from previous observations. This occurs frequently in spreadsheet-style…

Read more →
R

R tidyr - nest() and unnest()

List-columns are the foundation of tidyr’s nesting capabilities. Unlike typical data frame columns that contain atomic vectors (numeric, character, logical), list-columns contain lists where each…

Read more →