I would like to ask for your help with aggregating texts by group (dyad_id) and for each member. For each dyad, alter and ego took turns (sometimes they did not take turns, such as the third observation of dyad 111_222, where 222 initiated a new discussion).
I'm trying to combine all of the writings (with a space between each message) of each person within a focal dyad.
A sample data:
structure(list(dyad_id = c("111_222 ", "111_222 ", "111_222 ",
"333_111 ", "333_111 "), alter = c(111, 222, 222, 333, 111),
ego = c(222, 111, 111, 111, 333), message_original = c("Hello my idea is this ",
"I agree with your point ", "In this essay I would like to ",
"I think he should not ", "Can you tell me more "
), message_ego_response = c("I agree with your point ",
"Same here ", "That's a great idea ",
"Can you tell me more ", "Yes to elaborate "
)), class = "data.frame", row.names = c(NA, -5L), variable.labels = structure(character(0), names = character(0)), codepage = 65001L)
The above sample looks like:
+---------+-------+-----+-------------------------------+-------------------------+
| dyad_id | alter | ego | message_original | message_ego_response |
+---------+-------+-----+-------------------------------+-------------------------+
| 111_222 | 111 | 222 | Hello my idea is this | I agree with your point |
+---------+-------+-----+-------------------------------+-------------------------+
| 111_222 | 222 | 111 | I agree with your point | Same here |
+---------+-------+-----+-------------------------------+-------------------------+
| 111_222 | 222 | 111 | In this essay I would like to | That's a great idea |
+---------+-------+-----+-------------------------------+-------------------------+
| 333_111 | 333 | 111 | I think he should not | Can you tell me more |
+---------+-------+-----+-------------------------------+-------------------------+
| 333_111 | 111 | 333 | Can you tell me more | Yes to elaborate |
+---------+-------+-----+-------------------------------+-------------------------+
The output I'm looking for:
+---------+---------+-----------------------+---------+-------------------------------+------------------------------------+
| dyad_id | member1 | member1's messages | member2 | member2's messages | Note |
+---------+---------+-----------------------+---------+-------------------------------+------------------------------------+
| 111_222 | 111 | Hello my idea is this | 222 | I agree with your point | 222's "I agree with your point" is |
| | | Same here | | In this essay I would like to | a duplicate (one in 'message_ego' |
| | | That's a great idea | | | and the other in 'message_alter') |
+---------+---------+-----------------------+---------+-------------------------------+------------------------------------+
| 333_111 | 333 | I think he should not | 111 | Can you tell me more | Same here for the duplication |
| | | Yes to elaborate | | | |
+---------+---------+-----------------------+---------+-------------------------------+------------------------------------+