I have a dataframe with lines of text that look like this:
ANTALYA (GB) ch. 1960
SHOOTIN WAR (USA) ch. 1998
LORD AT WAR (ARG) ch. 1980
All caps are names, then location in (), color abbreviation, year. Names can be a few words. I want to split this single block of text into each component: name, location, color, year. I struggled with this for several days, and the best working solution I have is to simply put each word in separate columns, but it only works if the names have a certain length ... What do I do with the data, I can use it in this form, but it just doesn’t look beautiful, you know?
sepdf <- df %>%
separate(pedigree, into=c("Name1", "Name2", "Loc", "Col", "Year"),
sep=" ", merge=TRUE)
I tried to just keep the name using "(" as a separator between the two columns, but I don't think R likes it, I'm trying to use parentheses as a separator ...
Any suggestions would be very valuable.
source
share