0

我正在尝试创建一个 networkDynamic 对象,并尝试按照 oymonk 的帖子中的所有 skyebend 建议如何将数据帧上传到 R 中的 ndtv 以正确设置列的顺序以及正确设置每列的数据类型。不幸的是,我下面的示例继续返回,当 str() 清楚地表明我的起始列不是数字时。对于我所缺少的任何建议,我将不胜感激。

library("dplyr")
library("ndtv")

time = 
structure(list(onset = c(1571011200, 1571616000, 1571011200, 
1570406400, 1571616000, 1570406400, 1570406400, 1571011200, 1571011200, 
1571616000, 1572220800, 1570406400, 1570406400, 1571616000, 1571011200, 
1571011200, 1570406400, 1571616000, 1571011200, 1570406400, 1571616000, 
1570406400, 1571011200, 1570406400, 1570406400, 1570406400, 1571011200, 
1570406400, 1571616000, 1571616000, 1570406400, 1571011200, 1571011200, 
1570406400, 1570406400, 1571011200, 1572220800, 1571616000, 1571616000, 
1571011200, 1572220800, 1571616000, 1570406400, 1570406400, 1571011200, 
1571011200, 1571616000, 1571011200, 1571616000, 1571616000), 
    terminus = c(1571356800, 1571961600, 1571356800, 1570752000, 
    1571961600, 1570752000, 1570752000, 1571356800, 1571356800, 
    1571961600, 1572566400, 1570752000, 1570752000, 1571961600, 
    1571356800, 1571356800, 1570752000, 1571961600, 1571356800, 
    1570752000, 1571961600, 1570752000, 1571356800, 1570752000, 
    1570752000, 1570752000, 1571356800, 1570752000, 1571961600, 
    1571961600, 1570752000, 1571356800, 1571356800, 1570752000, 
    1570752000, 1571356800, 1572566400, 1571961600, 1571961600, 
    1571356800, 1572566400, 1571961600, 1570752000, 1570752000, 
    1571356800, 1571356800, 1571961600, 1571356800, 1571961600, 
    1571961600), tail = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
    10L, 11L, 12L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
    21L, 22L, 23L, 24L, 25L, 12L, 5L, 26L, 27L, 28L, 29L, 30L, 
    31L, 32L, 33L, 34L, 35L, 25L, 36L, 37L, 38L, 39L, 39L, 40L, 
    41L, 42L, 43L, 44L, 45L), head = c(307L, 308L, 309L, 310L, 
    307L, 311L, 312L, 308L, 313L, 313L, 308L, 309L, 308L, 308L, 
    308L, 308L, 314L, 307L, 315L, 308L, 307L, 308L, 314L, 313L, 
    309L, 313L, 308L, 315L, 313L, 312L, 310L, 309L, 307L, 309L, 
    308L, 308L, 313L, 308L, 316L, 312L, 312L, 307L, 315L, 309L, 
    317L, 317L, 307L, 312L, 309L, 314L)), row.names = c(NA, -50L
), class = c("tbl_df", "tbl", "data.frame"))

time_dyn = time %>% networkDynamic(edge.spell = .)

time %>% str()

我真的不明白我在这里缺少什么。任何帮助将不胜感激,如果需要任何其他信息来重现此示例,请告诉我。

4

1 回答 1

0

我不明白这背后的格式,但似乎将我的边缘列表从 tbldf 转换为常规数据框就可以了。

我只是通过在转换为 networkDynamic 之前执行以下操作来做到这一点

time = time %>% data.frame()
time = time %>% networkDynamic(edge.spells = time)
于 2020-06-03T15:31:20.317 回答