使用配对频率计数跟踪 R 错误



几天前这段代码运行良好,但现在它已经坏了:

links <- data.frame(source= c(1:3,4,6,8,10,10,12), target= c(1:3,5,1,10,4,4,9))
#View(links)
#source   target
#  1        1
#  2        2
#  3        3
#  4        5
#  6        1
#  8        10
#  10       4
#  10       4
#  12       9
relations <- links %>%
dplyr::group_by(source, target) %>%
count()
#View(relations) #Just getting one column with 2 everytime??
# V1
# 2
#Should've been and it used to be-
#source   target   count
#  1        1       1
#  2        2       1
#  3        3       1
#  4        5       1
#  6        1       1
#  8        10      1
#  10       4       2
#  12       9       1
Have tried %>% summarize(count =n()) too, no luck.

这个表达式一直有效到现在,就在今天早上重新运行代码,尝试追溯,我不知道发生了什么。

(代表问题作者发布解决方案以将其移动到答案空间(。

Rawr 和 akrun 给出了解决方案,基本上是我缺少count()函数的范围分辨率,应该dplyr::count()

最新更新