This is a bit challenging question (I guess), please hold on and read the entire bit, I promise it would be a satisfying result at the end (plus its about office the TV Show)
So I have a dataframe like this which can also be accessed like this
library(schrute)
office <- schrute::theoffice
OR below is dput output
structure(list(index = c(1L, 358L, 715L, 1072L, 1429L, 1786L,
2143L, 2500L, 2857L, 3214L), season = c("01", "01", "01", "01",
"01", "01", "01", "01", "01", "01"), episode = c("01", "01",
"01", "01", "01", "01", "01", "01", "01", "01"), episode_name = c(" Pilot",
" Pilot", " Pilot", " Pilot", " Pilot", " Pilot", " Pilot", " Pilot",
" Pilot", " Pilot"), character = c("Michael", "Jim", "Michael",
"Jim", "Michael", "Michael", "Michael", "Pam", "Michael", "Pam"
), text = c(" All right Jim. Your quarterlies look very good. How are things at the library?",
" Oh, I told you. I couldn't close it. So...", " So you've come to the master for guidance? Is this what you're saying, grasshopper?",
" Actually, you called me in here, but yeah.", " All right. Well, let me show you how it's done.",
" So that's the way it's done.", " I've, uh, I've been at Dunder Mifflin for 12 years, the last four as Regional Manager. If you want to come through here... See we have the entire floor. So this is my kingdom, as far as the eye can see. This is our receptionist, Pam. Pam! Pam-Pam! Pam Beesly. Pam has been with us for... forever. Right, Pam?",
" Well. I don't know.", " If you think she's cute now, you should have seen her a couple of years ago. [growls]",
" What?"), text_w_direction = c(" All right Jim. Your quarterlies look very good. How are things at the library?",
" Oh, I told you. I couldn't close it. So...", " So you've come to the master for guidance? Is this what you're saying, grasshopper?",
" Actually, you called me in here, but yeah.", " All right. Well, let me show you how it's done.",
" [on the phone] Yes, I'd like to speak to your office manager, please. Yes, hello. This is Michael Scott. I am the Regional Manager of Dunder Mifflin Paper Products. Just wanted to talk to you manager-a-manger. [quick cut scene] All right. Done deal. Thank you very much, sir. You're a gentleman and a scholar. Oh, I'm sorry. OK. I'm sorry. My mistake. [hangs up] That was a woman I was talking to, so... She had a very low voice. Probably a smoker, so... [Clears throat] So that's the way it's done.",
" I've, uh, I've been at Dunder Mifflin for 12 years, the last four as Regional Manager. If you want to come through here... See we have the entire floor. So this is my kingdom, as far as the eye can see. This is our receptionist, Pam. Pam! Pam-Pam! Pam Beesly. Pam has been with us for... forever. Right, Pam?",
" Well. I don't know.", " If you think she's cute now, you should have seen her a couple of years ago. [growls]",
" What?")), row.names = c(NA, -10L), class = c("tbl_df", "tbl",
"data.frame"))
What I want to create is a network graph probably in an effort to show who interacted with whom the most over the course of seasons. Trying to replicate something like this
(https://twitter.com/jakekaupp/status/1166874615286771717/photo/1)
I have no issues in creating nodes & edges and then proceeding to use ggraph, what I am struggling with is how to create a unique sequence for set of dialogues between each character something like scene or index variable which changes for every pair of character dialogues, its tricky & subjectie I get it because there is no straight forward way & hence would like to pick your brain how would you approach it if it had to be done.
If you see expected output basically I have created a variable Dialogue which actually identifies the characters between whom dialogue is happening. First it was Michael & Jim, then moved to Michael & Pam (hence the index has changed to 2). This probably could be done by manipulating character column and identifying change. That's where I need help ! Do let me know if there is anything additional needed on this. Thanks