2013-06-18 8 views
3

에 대한 속성으로 벡터를 할당하지만, 운이없는 :igraph 내가 정점 속성으로 벡터를 할당하려고 정점

# assignment of a numeric value (everything is ok) 
g<-set.vertex.attribute(g, 'checked', 2, 3) 
V(g)$checked 

. 이것이 가능하지 않은 것처럼 설명서를 확인한

# assignment of a vector (is not working) 
g<-set.vertex.attribute(g, 'checked', 2, c(3, 1)) 
V(g)$checked 

, http://igraph.sourceforge.net/doc/R/attributes.html 것 같습니다. 해결 방법이 있습니까? 까지 최대

지금 내가 가지고 올 수있는 유일한 사항은 다음과 같습니다

저장

  • 변환 벡터 문자열로 구분 저장의 문자열에 다른 구조에서이

    • 정보
  • 답변

    4

    괜찮습니다.

    ## replace c(3,1) by list(c(3,1)) 
    g <- set.vertex.attribute(g, 'checked', 2, list(c(3, 1))) 
    V(g)[2]$checked 
    [1] 3 1 
    

    편집 왜 작동합니까? 당신이 사용하는 경우 :

    number of items to replace is not a multiple of replacement length 
    

    가 실제로는 C (3,1)을 넣어하려고 길이 = 1의 변수에 길이 = 2가 있습니다

    g<-set.vertex.attribute(g, 'checked', 2, c(3, 1)) 
    

    당신은이 경고를 얻을 . 그래서 생각은 c (3,1)을 비슷하지만 길이가 1 인 것으로 대체하는 것입니다. 예 :

    length(list(c(3,1))) 
    [1] 1 
    > length(data.frame(c(3,1))) 
    [1] 1