There’s more!

See book chapter and especially the vignette!

  • drop or add a (wide-table) column name prefix with the names_prefix argument
  • drop ‘id’ columns (i.e. non-pivoted columns) in pivot_wider() with the id_cols argument
  • generate rows with missing values in pivot_wider() with the id_expand argument
  • aggregating values in pivot_wider()
  • combining pivot_longer() and pivot_wider() for more complex situations
  • for more complex cases, instead of names_* and values_* arguments, you can construct a single specification dataframe that you can provide to both pivot_longer_spec() and pivot_wider_spec()
  • and more