Skip to content

Transforming Data

Four videos covering column creation, aggregation, renaming, and reshaping data between long and wide formats.

Creating and modifying columns

The mutate expression block adds new columns or modifies existing ones using R expressions. Type an expression like bill_length_mm / 10 or paste(species, island, sep = " - ") and name the result column. You get the full power of R: any function available in your session can be used.

Summarising data

The summarize block aggregates data using functions like mean, sum, n, min, and max. Group by one or more columns to get summaries per group. For custom aggregation expressions, use the summarize expression block which accepts arbitrary R code.

Renaming, combining and splitting columns

Three related operations covered in one video:

  • Rename block: give columns clearer names without changing the data
  • Unite block: paste multiple columns together into one (e.g., combine first_name and last_name)
  • Separate block: split one column into multiple columns by a delimiter

Pivoting data

Reshape between long and wide formats:

  • Pivot longer: collapse multiple columns into key-value pairs (wide → long)
  • Pivot wider: spread key-value pairs into separate columns (long → wide)

These are essential when your data is in the wrong shape for a visualization or summary.

Next steps

Developed by cynkra and BMS