nei is a function that is used in V() subsetting, you need to call your data frame something else than nei.
Gabor On Fri, May 9, 2014 at 12:02 PM, Luca Rossi <[email protected]> wrote: > HI, > > I’m sorry. I’m trying to write here my code: > > MLau <- graph.data.frame(aucs.mlnet.v9,directed=FALSE) > > > MLau > IGRAPH UN-- 61 1240 -- > + attr: name (v/c), Label (e/c) > > V(MLau) > Vertex sequence: > [1] "U102" "U106" "U107" "U109" "U10" "U110" "U112" "U113" "U118" "U123" > "U124" "U126" "U130" "U134" "U138" "U139" > [17] "U13" "U140" "U141" “U142” … > > > nei <- > data.frame(user=MLcoauthor$V1,coauthor=MLcoauthor$V3,facebook=MLfacebook$V3,leisure=MLleisure$V3,lunch=MLlunch$V3,work=MLwork$V3,stringsAsFactors=FALSE) > > > head(nei) > user coauthor facebook leisure lunch work > 1 U102 0 0 0 2 0 > 2 U139 0 0 0 1 11 > 3 U33 0 0 0 6 9 > 4 U106 1 7 2 7 4 > > > > V(MLau)[nei$user]$nefacebook <- nei$facebook > > Error in nei$user : object of type 'closure' is not subsettable > > > thanks for helping! > > Luca > > > On 09 May 2014, at 17:10, Gábor Csárdi <[email protected]> wrote: > > You are doing something wrong. (It would be much easier to tell what, if > you showed me what you are doing, btw.) > > G. > > library(igraph) > df <- data.frame(id=sample(letters[1:5]), attr=1:5, > stringsAsFactors=FALSE) > df > # id attr > # 1 b 1 > # 2 c 2 > # 3 a 3 > # 4 e 4 > # 5 d 5 > > g <- graph.ring(5) > V(g)$name <- letters[1:5] > > V(g)[df$id]$attr <- df$attr > > get.data.frame(g, what="vertices") > # name attr > # a a 3 > # b b 1 > # c c 2 > # d d 5 > # e e 4 > > > > On Fri, May 9, 2014 at 10:59 AM, Luca Rossi <[email protected]> wrote: > >> Hi Gabor, >> >> thanks a lot. >> >> It gives me an error “ object of type 'closure' is not subsettable” >> that I don’t really understand. >> >> any idea? >> >> thanks! >> >> >> >> Luca Rossi >> >> >> >> On 09 May 2014, at 16:44, Gábor Csárdi <[email protected]> wrote: >> >> >> V(network)[dataframe$name]$attribute <- dataframe$attribute >> >> Untested, so please check the result. >> >> G. >> >> >> On Fri, May 9, 2014 at 10:34 AM, Luca Rossi <[email protected]> wrote: >> >>> Hi, >>> >>> I’m facing a problem that I guess should be quite simple but I can’t >>> find a good way to solve it. >>> I need to add to an igraph network vertex attributes that I have on a >>> dataframe. >>> >>> basically what I need to do is to add to V(network)[name==“X”] an >>> $attribute value taken from a data frame when name is equal to >>> dataframe$name. >>> The easiest way to do that I guess it would be to sort the vertex >>> sequence according to the name, is that possible? >>> >>> thanks a lot >>> >>> Luca >>> >>> >>> _______________________________________________ >>> igraph-help mailing list >>> [email protected] >>> https://lists.nongnu.org/mailman/listinfo/igraph-help >>> >> >> _______________________________________________ >> igraph-help mailing list >> [email protected] >> https://lists.nongnu.org/mailman/listinfo/igraph-help >> >> >> >> _______________________________________________ >> igraph-help mailing list >> [email protected] >> https://lists.nongnu.org/mailman/listinfo/igraph-help >> >> > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help > > > > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help > >
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
