A sample of my data looks like this.
Header: Time Sender Receiver
1 1 2
1 1 3
2 2 1
2 2 1
3 1 2
3 1 2
There are 3 time periods (sessions) and the edgelists between nodes.
I tried to write the code for subsetting data (for constructing a network)
based on time period as follows:
>uniq <-unique(unlist(df$Time))
>uniq [1] 1 2 3
>t=list()
>net=list()
>g=list()
>for (i in 1:length(uniq)) {
>t[[i]]<-subset(df, Time==uniq[i])
>t[[i]] <-as.matrix(t[[i]])
>net[[i]]<-t[[i]][,-1] #removing time column
# getting edgelist
>net[[i]][,1]=as.character (net[[i]][,1])
>net[[i]][,2]=as.character (net[[i]][,2])
>g [[i]]=graph.edgelist (net [[i]], directed=T)
>g [[i]] }
however, I've got an error message (expect two columns).I am kind of new to
R so it is hard to figure it out. I guess t[i] is the problem.
Is there anyone who can find my logical or syntax error in the code?
Jinie
[[alternative HTML version deleted]]