These functions offer tools for transforming manynet-consistent objects (matrices, igraph, tidygraph, or network objects). Transforming means that the returned object may have different dimensions than the original object.
to_ego() scopes a network into the local neighbourhood of a given node.
to_component() scopes a network to a single one of its components,
either the componentth largest or the one containing a named node.
It is the singular counterpart of to_components(),
which returns a list of all of them, largest first.
to_giant() scopes a network into one including only the main component
and no smaller components or isolates.
It is a wrapper, such that to_giant(.data) is to_component(.data, 1).
to_time() scopes a longitudinal network to the network as it stood at a given wave or time point.
to_wave() is an alias, using the wave-based vocabulary of net_waves() and to_waves().
For interval (spell) networks with tie begin/end lifespans, to_time()
returns the ties active at that moment, or – when time is omitted – a
list of slices, one per change point (each tie beginning or end).
to_no_isolates() scopes a network into one excluding all nodes without ties.
to_no_missing() scopes a network to one retaining only complete cases,
i.e. nodes with no missing values.
to_subgraph() scopes a network into a subgraph by filtering on some node-related logical statement.
to_blocks() reduces a network to ties between a given partition membership vector.
to_no_missing(.data)
to_ego(.data, node, max_dist = 1, min_dist = 0, direction = c("out", "in"))
to_time(.data, time = NULL)
to_wave(.data, time = NULL)
to_component(.data, component = 1, connectivity = c("weak", "strong"))
to_giant(.data, connectivity = c("weak", "strong"))
to_no_isolates(.data)
to_subgraph(.data, ...)
to_blocks(.data, membership, FUN = mean)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
Name or index of node.
The maximum breadth of the neighbourhood. By default 1.
The minimum breadth of the neighbourhood. By default 0. Increasing this to 1 excludes the ego, and 2 excludes ego's direct alters.
Character string, “out” bases the measure on outgoing ties, “in” on incoming ties, and "all" on either/the sum of the two. By default "all".
A time point or wave at which to present the network.
For an interval (spell) network that records tie begin/end lifespans,
time may be omitted, in which case a list of slices is returned,
one per change point (each moment at which some tie begins or ends).
Which component to retain. By default 1, i.e. the largest (giant) component, with 2 the second largest, and so on. Alternatively, the name of a node, in which case the component containing that node is retained.
Character string, "weak" treats a directed network's components as if the network were undirected, and "strong" requires ties in both directions between members. This is ignored for undirected networks, where the two notions coincide. Note that the default differs by function: marks that assert connectedness default to "strong", while functions that scope or split a network into components default to "weak".
Arguments passed on to dplyr::filter
A vector of partition memberships.
A function for summarising block content.
By default mean.
Other recommended options include median, sum,
min or max.
A tidygraph object modified as explained in the function description, details, or section.
Not all functions have methods available for all object classes. Below are the currently implemented S3 methods:
data.frame default igraph list matrix network tbl_graph
to_blocks * * * * * *
to_component * * * * * *
to_ego * * *
to_egos * * * * * *
to_no_isolates * * * * * * *
to_no_missing * *
to_subgraph * * * * * *
to_subgraphs * * * *For interval (spell) networks, whose ties carry begin/end lifespans
(e.g. irps_wwi), to_time() scopes to the ties active at time, using
the half-open convention (begin <= time < end) shared with
network::networkDynamic. When time is omitted, one such slice is
returned for each distinct change point (every moment at which some tie
begins or ends), as a named list, so that the evolving network can be
iterated over or animated (e.g. with autograph::grapht()).
to_blocks()Reduced graphs provide summary representations of network structures by collapsing groups of connected nodes into single nodes while preserving the topology of the original structures.
Other modifications:
modif_correlation,
modif_direction,
modif_from,
modif_labels,
modif_levels,
modif_miss,
modif_motifs,
modif_paths,
modif_permutation,
modif_plexity,
modif_project,
modif_split,
modif_weight
# A single snapshot of the ties active in a given year:
to_time(irps_wwi, 1901)
#>
#> ── # World War I Protagonists ──────────────────────────────────────────────────
#> # A dynamic, labelled, signed, undirected network of 6 European major powers
#> and 11 relationship ties from 1872 to 1918
#>
#> ── Nodes
#> # A tibble: 6 × 1
#> name
#> <chr>
#> 1 GBR
#> 2 FRA
#> 3 RUS
#> 4 AUH
#> 5 DEU
#> 6 ITA
#>
#> ── Ties
#> # A tibble: 11 × 5
#> from to sign begin end
#> <int> <int> <dbl> <dbl> <dbl>
#> 1 1 2 -1 1872 1904
#> 2 1 3 -1 1872 1907
#> 3 1 4 -1 1872 1918
#> 4 2 4 -1 1872 1918
#> 5 2 5 -1 1872 1918
#> 6 4 5 1 1872 1918
#> # ℹ 5 more rows
#>
# Or one slice per change point (each tie beginning or end):
length(to_time(irps_wwi))
#> [1] 7
to_component(fict_greys, 2)
#> ── # Component 2 of Grey's Anatomy ─────────────────────────────────────────────
#> # A labelled, undirected network of 6 nodes and 5 ties
#>
#> ── Nodes
#> # A tibble: 6 × 7
#> name sex race birthyear position season sign
#> <chr> <chr> <chr> <dbl> <chr> <dbl> <chr>
#> 1 Adele Webber F Black 1949 Non-Staff 2 "Leo"
#> 2 Catherine Avery F Other 1950 Attending 8 "Capricorn"
#> 3 Ellis Grey F White 1957 Attending 1 "Virgo"
#> 4 Susan Grey F White 1959 Non-Staff 2 "Taurus"
#> 5 Thatcher Grey M White 1955 Non-Staff 2 "Leo"
#> 6 Richard Webber M Black 1954 Chief 1 ""
#>
#> ── Ties
#> # A tibble: 5 × 2
#> from to
#> <int> <int>
#> 1 3 6
#> 2 3 5
#> 3 2 6
#> 4 4 5
#> 5 1 6
#>
to_component(fict_greys, "Miranda Bailey")
#> ── # Component containing Miranda Bailey of Grey's Anatomy ─────────────────────
#> # A labelled, undirected network of 4 nodes and 3 ties
#>
#> ── Nodes
#> # A tibble: 4 × 7
#> name sex race birthyear position season sign
#> <chr> <chr> <chr> <dbl> <chr> <dbl> <chr>
#> 1 Miranda Bailey F Black 1969 Attending 1 Virgo
#> 2 Ben Warren M Black 1972 Other 6 Aquarius
#> 3 Eli Lloyd M Black 1971 Nurse 7 Capricorn
#> 4 Tucker Jones M Black 1970 Non-Staff 2 Leo
#>
#> ── Ties
#> # A tibble: 3 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 4
#> 3 1 3
#>
to_giant(fict_greys)
#> ── # Giant component of Grey's Anatomy ─────────────────────────────────────────
#> # A labelled, undirected network of 40 nodes and 46 ties
#>
#> ── Nodes
#> # A tibble: 40 × 7
#> name sex race birthyear position season sign
#> <chr> <chr> <chr> <dbl> <chr> <dbl> <chr>
#> 1 Addison Montgomery F White 1967 Attending 1 Libra
#> 2 Teddy Altman F White 1969 Attending 6 Pisces
#> 3 Amelia Shepherd F White 1981 Attending 7 Libra
#> 4 Arizona Robbins F White 1976 Attending 5 Leo
#> 5 Rebecca Pope F White 1975 Non-Staff 3 Gemini
#> 6 Jackson Avery M Black 1981 Resident 6 Leo
#> # ℹ 34 more rows
#>
#> ── Ties
#> # A tibble: 46 × 2
#> from to
#> <int> <int>
#> 1 4 35
#> 2 16 35
#> 3 4 34
#> 4 4 30
#> 5 13 30
#> 6 16 30
#> # ℹ 40 more rows
#>
ison_adolescents |>
mutate_ties(wave = sample(1995:1998, 10, replace = TRUE)) |>
to_waves(attribute = "wave") |>
to_no_isolates()
#> $`1995`
#> ── # The Adolescent Society ────────────────────────────────────────────────────
#> # A longitudinal, labelled, undirected network of 5 adolescents and 5
#> friendship ties over 1995 waves
#>
#> ── Nodes
#> # A tibble: 5 × 1
#> name
#> <chr>
#> 1 Betty
#> 2 Sue
#> 3 Alice
#> 4 Dale
#> 5 Pam
#>
#> ── Ties
#> # A tibble: 5 × 3
#> from to wave
#> <int> <int> <int>
#> 1 1 2 1995
#> 2 2 3 1995
#> 3 3 4 1995
#> 4 2 5 1995
#> 5 3 5 1995
#>
#>
#> $`1996`
#> ── # The Adolescent Society ────────────────────────────────────────────────────
#> # A longitudinal, labelled, undirected network of 2 adolescents and 1
#> friendship ties over 1996 waves
#>
#> ── Nodes
#> # A tibble: 2 × 1
#> name
#> <chr>
#> 1 Jane
#> 2 Dale
#>
#> ── Ties
#> # A tibble: 1 × 3
#> from to wave
#> <int> <int> <int>
#> 1 1 2 1996
#>
#>
#> $`1997`
#> ── # The Adolescent Society ────────────────────────────────────────────────────
#> # A longitudinal, labelled, undirected network of 2 adolescents and 1
#> friendship ties over 1997 waves
#>
#> ── Nodes
#> # A tibble: 2 × 1
#> name
#> <chr>
#> 1 Sue
#> 2 Dale
#>
#> ── Ties
#> # A tibble: 1 × 3
#> from to wave
#> <int> <int> <int>
#> 1 1 2 1997
#>
#>
#> $`1998`
#> ── # The Adolescent Society ────────────────────────────────────────────────────
#> # A longitudinal, labelled, undirected network of 5 adolescents and 3
#> friendship ties over 1998 waves
#>
#> ── Nodes
#> # A tibble: 5 × 1
#> name
#> <chr>
#> 1 Alice
#> 2 Jane
#> 3 Pam
#> 4 Carol
#> 5 Tina
#>
#> ── Ties
#> # A tibble: 3 × 3
#> from to wave
#> <int> <int> <int>
#> 1 1 2 1998
#> 2 3 4 1998
#> 3 4 5 1998
#>
#>