The newly popular tidyr
package does this with separate
. It uses regular expressions so you'll have to escape the |
df <- data.frame(ID=11:13, FOO=c('a|b', 'b|c', 'x|y'))
separate(data = df, col = FOO, into = c("left", "right"), sep = "\\|")
ID left right
1 11 a b
2 12 b c
3 13 x y
though in this case the defaults are smart enough to work (it looks for non-alphanumeric characters to split on).
separate(data = df, col = FOO, into = c("left", "right"))