Question
How do I combine text names within an ordered transcription of dialogue?
Say I have this data:
df <- data.frame(x = c("Tom: I like cheese.",
"Tom: Cheese is good.",
"Tom: Muenster is my favorite.",
"Bob: No, I like Cheddar.",
"Tom: You're wrong. I think cheddar is only good on burgers.",
"Gina: But what about American on burgers?",
"Gina: That's better.",
"Bob: Yeah, I agree with Gina.",
"Bob: American is better on burgers. Cheddar is for grating on nachos."))
I want to turn it into this data:
df <- data.frame(x = c("Tom: I like cheese. Cheese is good. Muenster is my favorite.",
"Bob: No, I like Cheddar.",
"Tom: You're wrong. I think cheddar is only good on burgers.",
"Gina: But what about American on burgers? That's better.",
"Bob: Yeah, I agree with Gina. American is better on burgers. Cheddar is for grating on nachos."))
Basically, I want to cut the text including and before the colon on any instance of text that already has had a recent name.
I am struggling with trying to figure out how to do it in a way that doesn't group the entire "Tom:"'s and "Gina:"'s together and remove them all but for the first instance. I want the later mentions of names to restart the loop.
4 46
4