Skip to content

Instantly share code, notes, and snippets.

@ibombonato
Created October 18, 2016 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibombonato/556805b640b694331eed8be76421c071 to your computer and use it in GitHub Desktop.
Save ibombonato/556805b640b694331eed8be76421c071 to your computer and use it in GitHub Desktop.
How to transform rows to columns using spread in tidyr.
df <- data.frame(
id = c(1,1,2,2,2),
columnFields = c("column 1", "column 2", "column 1", "column 2", "column 3"),
valueFields = c(1:5))
tidyr::spread(df, columnFields, valueFields)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment