I have a data set:
crimes<-data.frame(x=c("Smith", "Jones"), charges=c("murder, first degree-G, manslaughter-NG", "assault-NG, larceny, second degree-G"))
I'm using tidyr:separate to split the charges column on a match with "G,"
crimes<-separate(crimes, charges, into=c("v1","v2"), sep="G,")
This splits my columns, but removes the separator "G,". I want to retain the "G," in the resulting column split.
My desired output is:
x v1 v2
Smith murder, first degree-G manslaughter-NG
Jones assault-NG larceny, second degree-G
Any suggestions welcome.