I need to parse a column created out of folder names. Some folders had many subfolders resulting in a variable amount of "/" in the name. How can I separate on "/" and end up with many columns, some of which will have "NA" if there were no subfolders?
Reprex:
df <- data.frame(group = c("a", "b", "c"), var1 = c(3, 1, 2),
id = c("C:/Users/me/big_folder/little_folder/plot/783/abc/551/statistics.csv",
"C:/Users/me/big_folder/little_folder/plot/rep/634/efg/552/statistics.csv",
"C:/Users/me/big_folder/228/hij/553/statistics.csv"))
separate(df, id, sep = "/", into = c(a, b, c, d, e, f, g, h, i, j))