Skip to content

Instantly share code, notes, and snippets.

@cecilialee
Last active March 2, 2018 22: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 cecilialee/61bec00ba4ed0406186a6f982d12cdca to your computer and use it in GitHub Desktop.
Save cecilialee/61bec00ba4ed0406186a6f982d12cdca to your computer and use it in GitHub Desktop.
Separate one column into multiple columns in R. #r #tidyr
library(tidyr)
library(dplyr)
df <- data.frame(x = c(NA, "a|b", "a|d", "b|c"))
df %>% separate(x, c("word1", "word2"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment