如何在Statnet的双向网络中将顶点属性仅分配给一种模式?

问题描述 投票:0回答:1

我目前正在使用具有两种不同模式和两组不同属性的双向网络。因此,第1行到第5行是一种模式,而参与者A,B和C是不同的模式,它们形成一些以1标记的连接。]

    a<-replicate( 3, numeric(5) )
    b<-apply(a, c(1,2), function(x) sample(c(0,1),1))
    rownames(b) <- rownames(c(1,2,3,4,5))
    colnames(b) <-colnames(c("A","B","C"))
    b
            A    B    C
    [1,]    1    0    1
    [2,]    1    0    1
    [3,]    0    0    0
    [4,]    0    1    1
    [5,]    1    1    0
c<-as.network(b, directed=T, bipartite =3)

    e<-c('A',"B","C")
    f<-c('tall','short','tall')
    g<-data.frame(e,f)
    colnames(g)<-c('person','height')
    g
      person height
          A   tall
          B  short
          C   tall

如何将数据帧g中的高度属性仅分配给角色A,B和C?到目前为止,我已经根据A,B和C的顶点位置尝试了set.vertex.attribute。

set.vertex.attribute(c, attrname= 'height', g$height, v = network.vertex.names(c)[6:9]) 

但出现以下错误

Vertex ID does not correspond to actual vertex in set.vertex.attribute.

我目前正在使用具有两种不同模式和两组不同属性的双向网络。因此,第1到第5行是一种模式,而参与者A,B和C是不同的模式,它们形成了一些...

networking attributes vertex bipartite statnet
1个回答
0
投票

思考

我想通了。我自己在双向网络中遇到了同样的问题,我从iGraph教程中借了一些代码。
© www.soinside.com 2019 - 2024. All rights reserved.