I have a dataframe, df, in which some of the values in the second column, alt, are separated by commas:
ref alt
ACTGG A,AATGG
GGC G,GG
GC G
AAT A,AA,AAA
Is there a way in R for me to duplicate each row that has comma-separated values in column df$alt such that each value is show individually? They would be duplicated number_of_commas+1 times to allow each comma-separated value to be shown once. Below is the output I'm be looking for:
ref alt
ACTGG AATGG
ACTGG A
GGC GG
GGC G
GC G
AAT AAA
AAT AA
AAT A
Again, this would only change the values in the second column. The first column, and any other potential columns, would simply be copied.