认为您的示例存在几个问题:
- 您将需要创建一个
networkDynamic
对象,而不是网络对象
- 您必须进行一些时间格式转换才能正确解析表格,并创建数字 ID
- 命令
render.animation()
不是animation.render()
首先,让我们设置一些我们可以加载的示例数据。只需要示例数据的前 4 列:
# text version of the example data
text<-"onset terminus tail head
9/6/2000 9/7/2000 mmmarcantel@equiva.com matthew.lenhart@enron.com
9/6/2000 9/7/2000 stephen.harrington@enron.com matthew.lenhart@enron.com
9/6/2000 9/7/2000 shelliott@dttus.com matthew.lenhart@enron.com
9/6/2000 9/7/2000 jilallen@dttus.com matthew.lenhart@enron.com
5/7/2001 5/8/2001 ken.shulklapper@enron.com matthew.lenhart@enron.com
9/6/2000 9/7/2000 eric.bass@enron.com matthew.lenhart@enron.com
9/6/2000 9/7/2000 shelliott@dttus.com matthew.lenhart@enron.com
9/6/2000 9/7/2000 bryan.hull@enron.com matthew.lenhart@enron.com
9/6/2000 9/7/2000 jilallen@dttus.com matthew.lenhart@enron.com
9/6/2000 9/7/2000 shelliott@dttus.com matthew.lenhart@enron.com
9/6/2000 9/7/2000 brook@pdq.net matthew.lenhart@enron.com
9/5/2000 9/6/2000 tlenhart@corealty.com matthew.lenhart@enron.com
9/5/2000 9/6/2000 patrick.ryder@enron.com matthew.lenhart@enron.com
9/5/2000 9/6/2000 eric.bass@enron.com matthew.lenhart@enron.com
9/5/2000 9/6/2000 mmmarcantel@equiva.com matthew.lenhart@enron.com
5/7/2001 5/8/2001 tlenhart@corealty.com matthew.lenhart@enron.com
9/5/2000 9/6/2000 tlenhart@corealty.com matthew.lenhart@enron.com
9/5/2000 9/6/2000 tlenhart@corealty.com matthew.lenhart@enron.com
9/5/2000 9/6/2000 paul.lucci@enron.com matthew.lenhart@enron.com
9/5/2000 9/6/2000 jilallen@dttus.com matthew.lenhart@enron.com
9/5/2000 9/6/2000 tlenhart@corealty.com matthew.lenhart@enron.com
9/5/2000 9/6/2000 paul.lucci@enron.com matthew.lenhart@enron.com
9/5/2000 9/6/2000 bryan.hull@enron.com matthew.lenhart@enron.com
9/5/2000 9/6/2000 shelliott@dttus.com matthew.lenhart@enron.com
8/31/2000 9/1/2000 bryan.hull@enron.com matthew.lenhart@enron.com
8/31/2000 9/1/2000 tlenhart@corealty.com matthew.lenhart@enron.com"
# 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()
但是,您的输入数据对我来说看起来有点滑稽。我很确定原始安然电子邮件数据的时间戳比发送电子邮件的日期更精确,并且发送每封电子邮件不应该花费一整天吗?如果您可以找到具有更精确时间戳的数据版本,您将在如何呈现和分析动态事件方面拥有更大的灵活性。例如,您将知道每天发送电子邮件的顺序等。