【发布时间】:2020-11-27 19:29:36
【问题描述】:
研究背景:演讲者(作者)和接受者就某个讨论主题进行书面交流。第一位发言者是发布主题的原始人。
数据如下:
structure(list(topic = c(1, 1, 1, 1, 1, 1, 2, 2), thread = c(1,
1, 1, 2, 2, 2, 3, 3), speaker_id = c(111, 111, 111, 222, 222,
222, 111, 222), recipient_id = c(222, 333, 444, 111, 555, 444,
222, 111), dyad = structure(c(1L, 2L, 3L, 1L, 5L, 4L, 1L, 1L), .Label = c("111_222",
"111_333", "111_444", "222_444", "222_555"), class = "factor")), class = "data.frame", row.names = c(NA,
-8L), codepage = 65001L)
目标是创建两个变量:
- threads_partnered:在一个讨论主题中,演讲者和接受者有多少个话题是合作的(即,组成二人组或直接互动)?
- threads_present:在一个讨论主题中,有多少个线程(除了给定线程)中,演讲者和接收者作为接收者出现,而不是合作(或形成二元组)?
根据示例数据,结果如下:
╔═══════╦════════╦═════════╦═══════════╦═════════╦═══════════╦══════════════════════════════════════════╦═════════╦════════════════════════════════════════════╗
║ topic ║ thread ║ speaker ║ recipient ║ dyad ║ threads ║ note ║ threads ║ note ║
║ ║ ║ id ║ id ║ ║ partnered ║ ║ present ║ ║
╠═══════╬════════╬═════════╬═══════════╬═════════╬═══════════╬══════════════════════════════════════════╬═════════╬════════════════════════════════════════════╣
║ 1.00 ║ 1 ║ 111 ║ 222 ║ 111_222 ║ 2 ║ 111 and 222 interacted (made a dyad) ║ 0 ║ Outside the given thread (thread #1) of ║
║ ║ ║ ║ ║ ║ ║ in two different threads (thread #1, #2) ║ ║ the given topic (topic #1), 111 and 222 ║
║ ║ ║ ║ ║ ║ ║ within topic 1 ║ ║ are not found together as recipients ║
║ ║ ║ ║ ║ ║ ║ ║ ║ other than being in a dyad ║
╠═══════╬════════╬═════════╬═══════════╬═════════╬═══════════╬══════════════════════════════════════════╬═════════╬════════════════════════════════════════════╣
║ 1.00 ║ 1 ║ 111 ║ 333 ║ 111_333 ║ 1 ║ 111 and 333 interacted in ║ 0 ║ ║
║ ║ ║ ║ ║ ║ ║ one thread (thread #1) ║ ║ ║
╠═══════╬════════╬═════════╬═══════════╬═════════╬═══════════╬══════════════════════════════════════════╬═════════╬════════════════════════════════════════════╣
║ 1.00 ║ 1 ║ 111 ║ 444 ║ 111_444 ║ 1 ║ 111 and 444 interacted in ║ 1 ║ 111 and 444 are found in thread #2, ║
║ ║ ║ ║ ║ ║ ║ one thread (thread #1) ║ ║ where they did not interact (made a dyad), ║
║ ║ ║ ║ ║ ║ ║ ║ ║ but were only recipients of ║
║ ║ ║ ║ ║ ║ ║ ║ ║ the original speaker (111) ║
╠═══════╬════════╬═════════╬═══════════╬═════════╬═══════════╬══════════════════════════════════════════╬═════════╬════════════════════════════════════════════╣
║ 1.00 ║ 2 ║ 222 ║ 111 ║ 111_222 ║ 2 ║ 111 and 222 interacted in two different ║ 0 ║ ║
║ ║ ║ ║ ║ ║ ║ threads within topic 1 ║ ║ ║
╠═══════╬════════╬═════════╬═══════════╬═════════╬═══════════╬══════════════════════════════════════════╬═════════╬════════════════════════════════════════════╣
║ 1.00 ║ 2 ║ 222 ║ 555 ║ 222_555 ║ 1 ║ 222 and 555 interacted in one thread ║ 0 ║ ║
╠═══════╬════════╬═════════╬═══════════╬═════════╬═══════════╬══════════════════════════════════════════╬═════════╬════════════════════════════════════════════╣
║ 1.00 ║ 2 ║ 222 ║ 444 ║ 222_444 ║ 1 ║ 222 and 444 interacted in one thread ║ 1 ║ 222 and 444 are found together ║
║ ║ ║ ║ ║ ║ ║ ║ ║ in thread #1, where they did not ║
║ ║ ║ ║ ║ ║ ║ ║ ║ interact ║
╠═══════╬════════╬═════════╬═══════════╬═════════╬═══════════╬══════════════════════════════════════════╬═════════╬════════════════════════════════════════════╣
║ 2.00 ║ 3 ║ 111 ║ 222 ║ 111_222 ║ 1 ║ 111 and 222 interacted in one thread ║ 0 ║ ║
║ ║ ║ ║ ║ ║ ║ (thread 3) within topic 2 ║ ║ ║
╠═══════╬════════╬═════════╬═══════════╬═════════╬═══════════╬══════════════════════════════════════════╬═════════╬════════════════════════════════════════════╣
║ 2.00 ║ 3 ║ 222 ║ 111 ║ 111_222 ║ 1 ║ same as above ║ 0 ║ ║
╚═══════╩════════╩═════════╩═══════════╩═════════╩═══════════╩══════════════════════════════════════════╩═════════╩════════════════════════════════════════════╝
【问题讨论】:
-
你能显示计算吗
-
@akrun 谢谢你,阿克伦。我在表格中添加了注释,解释了我脑海中的计算结果。这对你有意义吗?如果不清楚,请告诉我!
-
我认为你的第一列输出是
df1 %>% group_by(topic, dyad) %>% mutate(threds_partnered = n_distinct(thread)),第二我没有udnerstsand -
@akrun 谢谢!我会更清楚地编辑它。而第一个(thread_partnered)的目的是获取两个人“直接”交互的线程数,形成一个实际的二元组;第二个是关于两个人进行“间接”交互的线程数量,他们被列为收件人,但在该线程中彼此没有形成对偶。