'How to convert membership to dataframe

Following code returns nodes in this format

> membership(cluster_edge_betweenness(g))
 2  3  4  5  6  9 10 11 12  1  7  8 
 1  1  2  2  2  2  3  3  3  1  2  2 

How do I convert community membership for each node to a data frame?

> data.frame(membership(cluster_edge_betweenness(g)))
Error in as.data.frame.default(x[[i]], optional = TRUE) : 
  cannot coerce class ‘"membership"’ to a data.frame

I intend to store it to csv later. Thanks for answer.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source