Skip to contents

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 nested_egor
as_igraph(
  x,
  directed = FALSE,
  include.ego = FALSE,
  ego.attrs = NULL,
  ego.alter.weights = NULL,
  graph.attrs = ".egoID"
)

# S3 method for 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 egor
as.network(
  x,
  directed = FALSE,
  include.ego = FALSE,
  ego.attrs = NULL,
  ego.alter.weights = NULL,
  graph.attrs = ".egoID"
)

Arguments

x

An egor object.

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 .egoID is 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 a5b4983 UNW- 7 7 -- 
#> + attr: .egoID (g/n), name (v/c), sex (v/c), age (v/c), age.years
#> | (v/n), country (v/c), income (v/n), weight (e/n)
#> + edges from a5b4983 (vertex names):
#> [1] 6--7 3--7 4--5 2--6 1--7 1--6 3--4
#> 
#> $`2`
#> IGRAPH fed4531 UNW- 10 22 -- 
#> + attr: .egoID (g/n), name (v/c), sex (v/c), age (v/c), age.years
#> | (v/n), country (v/c), income (v/n), weight (e/n)
#> + edges from fed4531 (vertex names):
#>  [1] 3--8  6--8  1--6  4--8  9--10 5--7  1--10 3--7  8--10 4--5  7--9  3--4 
#> [13] 6--9  4--10 2--4  7--10 2--3  1--7  1--2  3--10 1--9  2--5 
#> 
#> $`3`
#> IGRAPH 8b19eb1 UNW- 14 49 -- 
#> + attr: .egoID (g/n), name (v/c), sex (v/c), age (v/c), age.years
#> | (v/n), country (v/c), income (v/n), weight (e/n)
#> + edges from 8b19eb1 (vertex names):
#>  [1] 2 --3  5 --10 1 --12 4 --5  6 --12 4 --9  7 --12 2 --10 1 --5  3 --11
#> [11] 1 --2  6 --11 2 --8  2 --13 2 --11 4 --10 2 --9  12--13 7 --8  2 --7 
#> [21] 1 --6  8 --11 11--12 10--12 3 --13 3 --10 4 --7  10--11 9 --12 13--14
#> [31] 3 --7  4 --12 1 --9  2 --6  1 --14 9 --13 1 --11 6 --9  11--13 5 --14
#> [41] 2 --14 8 --10 3 --6  3 --12 5 --13 10--13 12--14 4 --8  3 --4 
#>