Skip to content

Commit

Permalink
In as_tibble.network(), work around as_tibble.data.frame() stripping …
Browse files Browse the repository at this point in the history
…"n" attribute by assigning it after the coercion.

fixes #81
  • Loading branch information
krivit committed Apr 2, 2024
1 parent 5f28b1f commit 396bf81
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions R/coercion.R
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,10 @@ as_tibble.network<-function(x,attrnames=(match.arg(unit)=="vertices"),na.rm=TRUE
df <- df[intersect(c(".tail", ".head", ".eid", attrnames), names(df))]
for(a in setdiff(attrnames, names(df))) df[[a]] <- rep(list(), nrow(df))

attr(df,"n")<-network.size(x)
attr(df,"vnames")<-network.vertex.names(x)
if(is.bipartite(x))
attr(df,"bipartite")<-x%n%"bipartite"

as_tibble(df)
structure(as_tibble(df),
n = network.size(x),
vnames = network.vertex.names(x),
bipartite = x %n% "bipartite")
}

#' @rdname as.matrix.network
Expand Down

0 comments on commit 396bf81

Please sign in to comment.