认为您的示例存在几个问题:
- 你需要创建一个
networkDynamic
对象,而不是网络
目的
- 您将必须进行一些时间格式转换
表正确解析,以及创建数字 ID
- 命令是
render.animation()
not animation.render()
首先,让我们设置一些可以加载的示例数据。只需要示例数据的前 4 列:
# text version of the example data
text<-"onset terminus tail head
9/6/2000 9/7/2000 [email protected] [email protected]
9/6/2000 9/7/2000 [email protected] [email protected]
9/6/2000 9/7/2000 [email protected] [email protected]
9/6/2000 9/7/2000 [email protected] [email protected]
5/7/2001 5/8/2001 [email protected] [email protected]
9/6/2000 9/7/2000 [email protected] [email protected]
9/6/2000 9/7/2000 [email protected] [email protected]
9/6/2000 9/7/2000 [email protected] [email protected]
9/6/2000 9/7/2000 [email protected] [email protected]
9/6/2000 9/7/2000 [email protected] [email protected]
9/6/2000 9/7/2000 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
5/7/2001 5/8/2001 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
9/5/2000 9/6/2000 [email protected] [email protected]
8/31/2000 9/1/2000 [email protected] [email protected]
8/31/2000 9/1/2000 [email protected] [email protected]"
# write out the example data to an example input file
inputFile<-tempfile()
cat(text,file=inputFile)
现在,加载网络动态库
library(networkDynamic)
# read in tab-delimited example input file
timeData<-read.csv(inputFile,sep = "\t",stringsAsFactors = FALSE)
# check that it was loaded correctly
timeData
# convert the date formats into a numeric time (milliseconds)
timeData$onset<-as.numeric(as.POSIXct(timeData$onset,format='%m/%d/%Y'))
timeData$terminus<-as.numeric(as.POSIXct(timeData$terminus,format='%m/%d/%Y'))
# create a table of email address to map to numeric ids
emails<-unique(c(timeData$head,timeData$tail))
#covert ids
timeData$head<- match(timeData$head,emails)
timeData$tail<- match(timeData$tail,emails)
# convert to networkDynamic object
enronDyn<-networkDynamic(edge.spells=timeData)
# copy in the network names
network.vertex.names(enronDyn)<-emails
# load ndtv library
library(ndtv)
# compute the animation at 30-day interval
compute.animation(enronDyn,slice.par=list(start=967705200,end=989305200,interval=2592000,aggregate.dur=2592000,rule='latest'))
# render out the animation
render.animation(enronDyn)
ani.replay()
然而,你的输入数据对我来说看起来有点有趣。我很确定原始的安然电子邮件数据具有比电子邮件发送当天更精确的时间戳,并且发送每封电子邮件不应该花费一整天的时间?如果您可以找到具有更精确时间戳的数据版本,那么您在呈现和分析动态事件的方式上将具有更大的灵活性。例如,您将知道每天发送电子邮件的顺序等。