Skip to content

Instantly share code, notes, and snippets.

@alexpghayes
Last active July 31, 2018 16:57
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 alexpghayes/d66bdd4c3e05b93282a80b71479ee679 to your computer and use it in GitHub Desktop.
Save alexpghayes/d66bdd4c3e05b93282a80b71479ee679 to your computer and use it in GitHub Desktop.
irene's example of how to undo model.matrix
data <- tibble(species = c("raccoon", "kakapo", "bedbug"),
weight_f = c(10, 3, .1),
weight_m = c(11, 5, .1),
height_f = c(11, 11, .2),
height_m = c(10, 10, .1))
data %>%
gather(key, value, -species) %>%
separate(key, c("meas", "sex")) %>%
spread(meas, value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment