These functions reformat manynet-consistent data.

  • to_anti() reformats network data into its complement, where only ties not present in the original network are included in the new network.

  • to_simplex() reformats complex network data, containing loops, to simplex network data, without any loops.

  • to_uniplex() reformats multiplex network data to a single type of tie. to_layer() is an alias, using the layer-based vocabulary of layer_names(), net_layers(), and to_layers(). Use to_layers() to split a network into all of its layers at once.

  • to_flat() reduces multiplex network data to a single relation by combining the values of all its layers, dyad by dyad, according to a rule. Where to_uniplex() selects one layer and discards the rest, to_flat() retains what every layer records.

If the format condition is not met, for example to_undirected() is used on a network that is already undirected, the network data is returned unaltered. No warning is given so that these functions can be used to ensure conformance.

Unlike the as_*() group of functions, these functions always return the same class as they are given, only transforming these objects' properties.

to_anti(.data)

to_simplex(.data)

to_uniplex(.data, layer, tie)

to_layer(.data, layer, tie)

to_flat(.data, rule = c("max", "min", "mean", "sum", "product"))

Arguments

.data

An object of a {manynet}-consistent class:

  • adjacency or incidence matrix from {base} R

  • edgelist data.frame from {base} R or tbl/tbl_df from {tibble}

  • stocnet stocnet, from the {manynet} package

  • igraph igraph, from the {igraph} package

  • network network, from the {network} package

  • tidygraph tbl_graph, from the {tidygraph} package

layer

Character string naming one of the layers, or tie types, in the network, i.e. one of those returned by layer_names(), to which the network should be reduced. Where a network holds no tie types, it is already uniplex and is returned unchanged.

tie

Deprecated name for layer, retained for one version.

rule

How the networks' tie values are reconciled into a single value per dyad. A dyad tied in only one of the networks counts as untied in the others, which is what makes rules such as "min" and "product" meaningful.

  • "max" (the default) takes the largest of the values, so that a tie in any of the networks is a tie in the result. This is the union of the networks.

  • "min" takes the smallest, so that only ties present in all of them survive. This is their intersection.

  • "mean" averages the values, treating the networks as several readings of one underlying relationship.

  • "sum" adds them, so that ties reinforce one another.

  • "product" multiplies them, so that a tie survives only where every network records one, and strong ties are rewarded disproportionately.

Missing values propagate rather than being ignored, so that a dyad unobserved in any of the networks is unobserved in the result. Use impute_ties() first to state a different assumption.

Value

An object of the same class as the function was given, modified as explained in the function description, details, or section. Functions that split a network return a list of such objects.

Details

Not all functions have methods available for all object classes. Below are the currently implemented S3 methods:

Warning in utils::.S3methods(f): generic function 'to_layer' dispatches methods
for generic 'to_uniplex'
Warning in utils::.S3methods(f): generic function 'to_layer' dispatches methods
for generic 'to_uniplex'
           data.frame default igraph matrix stocnet tbl_graph
to_anti             *       *      *      *                 *
to_flat                     *                               *
to_simplex          *       *      *      *       *         *
to_uniplex                  2                               2

Examples

to_anti(ison_southern_women)
#> # A labelled, two-mode network of 18 nodes and 14 nodes and 163 ties
#> 
#> ── Nodes 
#> # A tibble: 32 × 2
#>   type  name     
#>   <lgl> <chr>    
#> 1 FALSE Evelyn   
#> 2 FALSE Laura    
#> 3 FALSE Theresa  
#> 4 FALSE Brenda   
#> 5 FALSE Charlotte
#> 6 FALSE Frances  
#> # ℹ 26 more rows
#> 
#> ── Ties 
#> # A tibble: 163 × 2
#>    from    to
#>   <int> <int>
#> 1     1    25
#> 2     1    28
#> 3     1    29
#> 4     1    30
#> 5     1    31
#> 6     1    32
#> # ℹ 157 more rows
#> 
as_tidygraph(create_filled(5)) |>
  mutate_ties(type = sample(c("friend", "enemy"), 10, replace = TRUE)) |>
  to_uniplex("friend")
#> ── # Filled network ────────────────────────────────────────────────────────────
#> # A undirected network of 5 nodes and 6 friend ties
#> 
#> ── Ties 
#> # A tibble: 6 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     1     4
#> 3     1     5
#> 4     2     5
#> 5     3     4
#> 6     4     5
#> 
to_flat(ison_florentine, rule = "sum")
#> # A labelled, weighted, undirected network of 16 nodes and 27 ties
#> # Transformed by aggregation: layers (sum)
#> 
#> ── Nodes 
#> # A tibble: 16 × 4
#>   label      wealth priorates totalties
#>   <chr>       <int>     <int>     <int>
#> 1 Acciaiuoli     10        53         2
#> 2 Albizzi        36        65         3
#> 3 Barbadori      55         0        14
#> 4 Bischeri       44        12         9
#> 5 Castellani     20        22        18
#> 6 Ginori         32         0         9
#> # ℹ 10 more rows
#> 
#> ── Ties 
#> # A tibble: 27 × 3
#>    from    to weight
#>   <int> <int>  <dbl>
#> 1     1     9      1
#> 2     2     6      1
#> 3     2     7      1
#> 4     2     9      1
#> 5     3     5      2
#> 6     3     6      1
#> # ℹ 21 more rows
#>