Learn R Programming

intergraph (version 1.2-0)

asDF: Convert network to data frame(s)

Description

Convert a network to, possibly two, data frames: an edge list with edge attributes (if any), and data frame of vertexes with vertex attributes (if any). This is a generic function, see below for available methods.

Usage

asDF(object, ...)

Arguments

object
R object representing a network, see below for available methods
...
other arguments passed to/from other methods

Value

  • List with two components: edges containing an edge list at first two columns and edge attributes on further ones. vertexes with vertex id in the first column, named id and any vertex attributes in the other columns.

Details

Currently there are methods for object being in one of the following classes: "network", "igraph". The function first gets the graph edge list using the appropriate function depending on the class of object (see below). Edge attributes, if any, are then extracted using dumpAttr and added to it. The vertex data frame is constructed with a vertex id as a sequence of integer numbers. Details are method-specific, see below. Vertex attributes are extracted with dumpAttr and added to this data frame.

Examples

Run this code
# using method for 'network' objects
d1 <- asDF(exNetwork)
str(d1)

# using method for 'igraph' objects
d2 <- asDF(exIgraph)
str(d2)

Run the code above in your browser using DataLab