File: asDF.Rd

package info (click to toggle)
r-cran-intergraph 2.0-4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 392 kB
  • sloc: sh: 13; makefile: 2
file content (77 lines) | stat: -rw-r--r-- 2,731 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/asDF.R
\name{asDF}
\alias{asDF}
\alias{asDF.network}
\alias{asDF.igraph}
\title{Convert network to data frame(s)}
\usage{
asDF(object, ...)

\method{asDF}{network}(object, ...)

\method{asDF}{igraph}(object, ...)
}
\arguments{
\item{object}{R object representing a network, see below for available
methods}

\item{\dots}{other arguments passed to/from other methods}
}
\value{
List with two components:
\describe{
\item{\code{edges}}{containing an edge list data frame at first two columns
and edge attributes on further ones.}
\item{\code{vertexes}}{with vertex id in the first column, named \code{id}
and any vertex attributes in the other columns.}
}
}
\description{
Convert a network data object to, possibly two, data frames: a data frame
with an edge list with edge attributes (if any), and a data frame of vertexes
with vertex attributes (if any). This is a generic function, see below for
available methods.
}
\details{
Currently there are methods for \code{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 \code{object} (see below).  Edge attributes, if
any, are then extracted using \code{\link{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 \code{\link{dumpAttr}} and added to this data frame.

Method-specific notes:

For objects of class "network". Objects of this class store the vertex ids
as integer numbers. There is also an attribute "vertex.names" which is
always created when using graph constructors provided in the package
\pkg{network}.  \code{asDF} adds "vertex.names" to the vertex data frame as
a normal attribute and does not use it as a vertex id in the edge list.

The edge list is created using \code{\link[network]{as.matrix.network}}
function and contains integer vertex ids.

Objects of class "igraph", as provided by the \pkg{igraph} package. Vertex
ids in these objects integers starting from 1 (in \pkg{igraph} version prior
to 0.6-0 vertex ids started from 0). However, it is also possible to provide
a vertex attribute "name". It is added to the vertex data frame as a normal
vertex attribute and is not used on the edge list data frame.

The edge list is created using \code{\link[igraph]{get.edgelist}} function
with argument \code{names} set to \code{FALSE} so that integer vertex ids
are used.
}
\examples{
# using method for 'network' objects
d1 <- asDF(exNetwork)
str(d1)

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