I have a columns within my tibble called sourceMedium with strings like so:
"apples / pears"
I want to mutate this into two new columns and then to remove the original one. I'm trying to do this within a dplyr chain of operations and I just can't get it:
wrangled <- gaDataSessionsAggregate %>%
+ mutate(source = unlist(strsplit(sourceMedium, "/"))[1],
medium = unlist(strsplit(sourceMedium, "/"))[2])
This runs but I only get one unique value in each of the two new fields. There should be many unique values within each new field based on the original column. It looks like r is keeping the first value in the tibble and applying it to every other instance in the columns.
What is the shortest, most "dplyr esque" way to take field sourceMedium and split into two new fields "source" and "medium" based on a slash separator "/"?