'How to save an igraph object

I have a problem writing my data frame to csv file.

g looks like this

> g
IGRAPH c32bbbf UN-- 12 12 -- 
+ attr: name (v/c)
+ edges from c32bbbf (vertex names):
 [1] 2 --3  3 --1  4 --5  5 --6  4 --6  6 --7  6 --8  6 --9  9 --8  10--11 11--12 10--12

None of folowing code works

write.table(g,  file = "filename.csv", sep = ";", dec = ",", row.names = FALSE)
write.csv2(membership(cluster_edge_betweenness(g)), "name.csv" , row.names = FALSE)
write.table(membership(cluster_edge_betweenness(g)),  file = "name.csv", sep = ";", dec = ",", row.names = FALSE)

It shows this error

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

How can I write g or membership(cluster_edge_betweenness(g)) into a .csv file? Thanks for help in advance.



Solution 1:[1]

Use igraph's write_graph() function. Check the documentation for available formats.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Szabolcs