我有关于大学俱乐部每周社交小时活动中可能发生和实际发生的每一个互动的数据。
以下是我的一部分数据:
structure(list(from = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("A",
"B", "C"), class = "factor"), to = structure(c(2L, 3L, 2L, 3L,
2L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("A",
"B", "C"), class = "factor"), timestalked = c(0L, 1L, 0L, 4L,
1L, 2L, 0L, 1L, 0L, 2L, 1L, 0L, 1L, 2L, 1L, 0L, 0L, 0L), week = structure(c(1L,
1L, 3L, 3L, 2L, 2L, 1L, 1L, 3L, 3L, 2L, 2L, 1L, 1L, 3L, 3L, 2L,
2L), .Label = c("1/1/2010", "1/15/2010", "1/8/2010"), class = "factor")), .Names = c("from",
"to", "timestalked", "week"), class = "data.frame", row.names = c(NA,
-18L))
我正在尝试计算每个星期、最近两周和今年到目前为止每个人(A、B、C)的网络统计数据,例如中心性。我唯一成功的方法是手动将文件按照所需的时间单位拆分,但一定有更简单的方法。
当
timestalked
为0时,应视为无边。输出将生成以下
.csv
:actor cent_week1 cent_week2 cent_week3 cent_last2weeks cent_yeartodate
A
B
C
cent_week1
是指 2010年1月1日的中心度;cent_last2weeks
只考虑了 2010年1月8日和1月15日;cent_yeartodate
则是同时考虑了所有的数据。这将应用于一个更大的数百万观测值的数据集。
b = by(d, d$week, FUN=graph_from_data_frame)
,然后在它们上运行函数sapply(b, function(x) eigen_centrality(x, weights = E(x)$timestalked)$vector)
(不确定是否合理)。 - user20650week1
,week2
,week3
,last2weeks
和yeartodate
的具体含义?week1 == 1/1/2010
?week2 == 1/8/2010
?last2weeks ==
?... - nghauran