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. Parallel ties are kept, since a second tie between two nodes is not a loop; tie_is_parallel() marks them.

  • 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_aggregated() combines the ties of a network that differ only in one tie column, dyad by dyad, according to a rule: its layers, the reports of its reporters, the gossip about each target, or its moments. It can also combine parallel ties. Where to_uniplex() selects one layer and discards the rest, to_aggregated() retains what every layer records. to_flat() is an alias that combines layers, and takes the rule as its second argument.

  • to_disaggregated() turns tie weights back into that many parallel ties, reversing to_aggregated(over = NULL, rule = "sum").

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_aggregated(
  .data,
  over = "layer",
  rule = c("max", "min", "mean", "sum", "product"),
  reporters = c("all", "sender", "receiver", "both")
)

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

to_disaggregated(.data)

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.

over

The tie column over which ties are combined, one of the columns that as_stocnet() takes from the third dimension of an array:

  • "layer" (the default) combines the layers of a multiplex network,

  • "by" combines the reports of the reporters in a cognitive social structure,

  • "about" combines the gossip about each target,

  • "time" combines the moments of a longitudinal network.

NULL combines only parallel ties, the ties that tie_is_parallel() marks. to_disaggregated() reverses this where rule = "sum".

Each tie counts by its weight, or by its sign where it has no weight, and otherwise as 1. Signed values can cancel one another out, and a combined value of zero is no tie.

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.

reporters

Which reports are combined where over = "by":

  • "all" (the default) combines the reports of every reporter.

  • "sender" takes, for the tie from i to j, the report of i.

  • "receiver" takes, for the tie from i to j, the report of j.

  • "both" combines the reports of i and j by the rule. With rule = "min" this is the intersection locally aggregated structure of Krackhardt (1987), and with rule = "max" it is the union one.

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'
                 array data.frame default igraph matrix stocnet tbl_graph
to_aggregated        *                  *                     *         *
to_anti                         *       *      *      *                 *
to_disaggregated                        *             *       *
to_simplex                      *       *      *      *       *         *
to_uniplex                              2                               2

Aggregating reports

Over reporters, "max" gives a tie where any reporter reports one, "min" where all of them do, "mean" the share of the reporters that do, and "sum" how many of them do. A consensus structure is therefore to_aggregated(.data, over = "by", rule = "mean") followed by to_unweighted(threshold = 0.5). A reporter that did not report is left out of the reports that are combined, rather than making every tie missing, and a tie is missing only where none of the reporters it is pooled over reported it. Egocentric data has no roster that all the egos report on, so its reports cannot be combined.

Disaggregating

to_disaggregated() turns each tie of weight w into w parallel ties, and so reverses to_aggregated(over = NULL, rule = "sum"). No other aggregation can be reversed, since the values it combined are not kept; to_layers(), to_reporters(), and to_times() split a network into its parts without losing them. The weights must be whole numbers. A negative weight becomes that many negative ties, held as weights of -1, which is how a signed network holds its signs. A matrix cannot hold parallel ties, so it is returned as it is.

References

On aggregating cognitive social structures

Krackhardt, David. 1987. "Cognitive social structures". Social Networks, 9(2): 109-134. doi:10.1016/0378-8733(87)90009-8

Examples

to_anti(ison_southern_women)
#> # A labelled, two-mode network of 18 FALSEs and 14 TRUEs and 163 ties
#> 
#> ── Nodes 
#> # A tibble: 32 × 2
#>   label     mode 
#>   <chr>     <chr>
#> 1 Evelyn    FALSE
#> 2 Laura     FALSE
#> 3 Theresa   FALSE
#> 4 Brenda    FALSE
#> 5 Charlotte FALSE
#> 6 Frances   FALSE
#> # ℹ 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 7 friend ties
#> 
#> ── Ties 
#> # A tibble: 7 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     1     3
#> 3     1     5
#> 4     2     3
#> 5     3     4
#> 6     3     5
#> # ℹ 1 more row
#> 
to_aggregated(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
#> 
to_disaggregated(to_aggregated(ison_koenigsberg, over = NULL, rule = "sum"))
#> ── # Seven Bridges of Koenigsberg ──────────────────────────────────────────────
#> # A labelled, undirected network of 4 landmasses and 7 bridge ties (4 parallel)
#> # Transformed by aggregation and disaggregation
#> 
#> ── Nodes 
#> # A tibble: 4 × 3
#>   label      lat   lon
#>   <chr>    <dbl> <dbl>
#> 1 Altstadt  54.7  20.5
#> 2 Kneiphof  54.7  20.5
#> 3 Lomse     54.7  20.5
#> 4 Vorstadt  54.7  20.5
#> 
#> ── Ties 
#> # A tibble: 7 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     1     2
#> 3     1     3
#> 4     2     3
#> 5     2     4
#> 6     2     4
#> # ℹ 1 more row
#>