These functions convert an egor object into a list of network or igraph objects.
By default ego itself is not included in the created objects, there is
a parameter (include.egor) that allows for including ego.
Usage
as_igraph(
x,
directed = FALSE,
include.ego = FALSE,
ego.attrs = NULL,
ego.alter.weights = NULL,
graph.attrs = ".egoID"
)
# S3 method for class 'egor'
as.igraph(
x,
directed = FALSE,
include.ego = FALSE,
ego.attrs = NULL,
ego.alter.weights = NULL,
graph.attrs = ".egoID"
)
as_network(
x,
directed = FALSE,
include.ego = FALSE,
ego.attrs = NULL,
ego.alter.weights = NULL,
graph.attrs = ".egoID"
)
# S3 method for class 'egor'
as.network(
x,
directed = FALSE,
include.ego = FALSE,
ego.attrs = NULL,
ego.alter.weights = NULL,
graph.attrs = ".egoID"
)Arguments
- x
An
egorobject.- directed
Logical, indicating if alter-alter relations are directed.
- include.ego
Logical.Should ego be included?- ego.attrs
Vector of names (character) or indices (numeric) of ego variables that should be carried over to the network/ igraph objects. This is ignored, when
include.ego = FALSE(default).- ego.alter.weights
Vector of names (character) or indices (numeric) of alter variables that should be carried over to the the network/ igraph objects, as edge attributes of the ego-alter relations. This is ignored, when `include.ego = FALSE“ (default).
- graph.attrs
Vector of names (character) or indices (numeric) of ego variables that are supposed to be carried over to the igraph object as graph attributes or the network object as network attributes. By default
.egoIDis carried over.
Details
The names of the variables specified in ego.attr and ego.alter.attr need to be the same as the names of corresponding alter attributes, in order for those variables to be merged successfully in the resulting network/ igraph object (see example).
Examples
e <- make_egor(3, 22)
as_igraph(e)
#> [[1]]
#> IGRAPH 789404c DNW- 22 120 --
#> + attr: .egoID (g/c), name (v/c), .egoID (v/c), sex (v/c), age (v/x),
#> | age.years (v/n), country (v/c), income (v/n), .egoID (e/c), weight
#> | (e/n)
#> + edges from 789404c (vertex names):
#> [1] 5 ->13 17->20 15->20 1 ->11 13->21 4 ->5 7 ->15 8 ->15 4 ->16 9 ->11
#> [11] 6 ->15 1 ->21 7 ->17 9 ->17 2 ->16 4 ->8 9 ->14 16->22 5 ->20 10->13
#> [21] 6 ->17 6 ->18 8 ->13 1 ->14 11->17 11->15 11->20 8 ->12 4 ->22 4 ->10
#> [31] 10->19 7 ->16 3 ->14 4 ->15 12->20 3 ->20 18->20 6 ->10 11->12 4 ->12
#> [41] 8 ->20 21->22 2 ->12 16->20 5 ->19 11->18 15->22 9 ->12 8 ->9 4 ->9
#> [51] 1 ->16 3 ->13 2 ->13 6 ->9 9 ->18 7 ->13 1 ->19 13->14 18->19 1 ->7
#> + ... omitted several edges
#>
#> [[2]]
#> IGRAPH 4dd9d1b DNW- 8 12 --
#> + attr: .egoID (g/c), name (v/c), .egoID (v/c), sex (v/c), age (v/x),
#> | age.years (v/n), country (v/c), income (v/n), .egoID (e/c), weight
#> | (e/n)
#> + edges from 4dd9d1b (vertex names):
#> [1] 1->8 4->6 1->5 5->8 2->4 2->5 1->6 2->6 6->8 3->4 1->4 7->8
#>
#> [[3]]
#> IGRAPH 9c96462 DNW- 11 25 --
#> + attr: .egoID (g/c), name (v/c), .egoID (v/c), sex (v/c), age (v/x),
#> | age.years (v/n), country (v/c), income (v/n), .egoID (e/c), weight
#> | (e/n)
#> + edges from 9c96462 (vertex names):
#> [1] 2 ->4 1 ->9 2 ->11 6 ->8 1 ->3 8 ->10 4 ->6 3 ->9 3 ->7 7 ->9
#> [11] 6 ->10 3 ->6 6 ->7 1 ->8 5 ->8 4 ->7 3 ->4 5 ->9 3 ->11 7 ->11
#> [21] 8 ->11 7 ->10 2 ->5 2 ->9 10->11
#>