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 network to the network as it stood at a given
moment, in whichever of the ways set out in the Time section it records
time. to_wave() is an alias, using the wave-based vocabulary of
net_waves() and to_waves(). For one network per moment, see
to_times().
to_subgraph() scopes a network into a subgraph by filtering on some node-related logical statement.
to_blockmodel() reduces a network to the ties between the blocks of a
given partition membership vector.
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_subgraph(.data, ...)
to_blockmodel(.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 moment at which to present the network. A moment beyond the last one the network records reverts to the last, except in an interval network, which is defined between the moments it records as well as at them.
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. For two-mode networks this is a single vector covering the nodes in both modes, and not one vector per mode; the blocks of each mode are established separately from it, so that the result has one row per block of the first mode and one column per block of the second.
A function for summarising block content.
By default mean.
Other recommended options include median, sum,
min or max.
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.
Not all functions have methods available for all object classes. Below are the currently implemented S3 methods:
Two things about how a network records time are independent of each other, and the network is scoped to a moment by both of them.
How a moment is represented can be read from the ties. A network either stamps each tie with the point it was recorded at, in a 'time' column, or states the interval each tie lasts over, in 'begin' and 'end' columns.
How a moment relates to the one before it cannot be read from the ties,
and the network declares it in info$update. Where this is "replace",
which it is by default, each moment re-states the ties, so the network at
a moment is the ties stamped with it. Where it is "increment", each row
is a change to a tie's value, so the network at a moment is every row up
to and including it, accumulated, and a tie that has accumulated to zero
is no longer a tie. An interval tie carries its own lifespan, so nothing
is declared about it: it is active at a moment where it began at or
before that moment and has not yet ended (begin <= time < end, the
half-open convention shared with network::networkDynamic, so a tie that
ends and one that begins at the same instant do not overlap). A tie with
no 'end' is right-censored, and active from its beginning onwards.
info$observation records a third thing, how densely the network is
observed: a "panel" of a few complete re-observations, or a stream of
many "event" records. This describes a network rather than scoping it.
The two go together without entailing each other: a panel re-observes
the whole network at each wave and so is usually "replace", and an event
stream is often "increment", but an event that states a value afresh is
"replace" too. is_longitudinal() marks the first, is_dynamic() the
second, and no network is both.
In every case the nodal changes recorded up to the moment are applied, and a layer that states something holding throughout is carried into whichever moment is asked for, since such a layer is a constant covariate rather than an observation of that moment. A layer holds throughout where the network declares it "cross-sectional", or where it records that layer at a single moment while another layer spans several.
to_blockmodel()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.
Like the other scoping functions, the reduced graph is returned in the
same class as the input: a blockmodel matrix of summarised block content
for matrix input, and the corresponding weighted network otherwise.
Memberships are usually obtained from one of the node_in_*() functions
in {netrics}.
to_times() for one network per moment, and net_times() for how
many moments there are to ask for.
Other modifications:
modif_backbone,
modif_direction,
modif_from,
modif_labels,
modif_levels,
modif_miss,
modif_motifs,
modif_paths,
modif_permutation,
modif_plexity,
modif_project,
modif_proximity,
modif_split,
modif_weight
# The ties a panel observed in a given wave:
to_time(ison_monks, 2)
#>
#> ── # Sampson's Monks ───────────────────────────────────────────────────────────
#> # A labelled, multiplex, signed, weighted, directed network of 18 nodes and 57
#> like arcs, 112 esteem arcs, 103 influence arcs, and 80 praise arcs
#> # Transformed by exclusion: not tied at time 2 (111 ties excluded)
#>
#> ── Nodes
#> # A tibble: 18 × 3
#> label groups left
#> <chr> <chr> <dbl>
#> 1 Romuald Interstitial 3
#> 2 Bonaventure Loyal 4
#> 3 Ambrose Loyal 4
#> 4 Berthold Loyal 4
#> 5 Peter Loyal 3
#> 6 Louis Loyal 4
#> # ℹ 12 more rows
#>
#> ── Ties
#> # A tibble: 352 × 4
#> from to weight layer
#> <int> <int> <dbl> <chr>
#> 1 1 2 1 like
#> 2 1 5 3 like
#> 3 1 15 2 like
#> 4 2 3 1 esteem
#> 5 2 5 3 esteem
#> 6 2 5 3 influence
#> # ℹ 346 more rows
#>
# The ties an interval network held in a given year:
to_time(irps_wwi, 1901)
#> # A dynamic, labelled, signed, undirected network of 6 nodes and 11 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
#>
# The state an event network had accumulated to by a given day:
to_time(irps_nuclear, as.Date("2011-04-01"))
#> ── # German nuclear discourse network ──────────────────────────────────────────
#> # A dynamic, labelled, signed, two-mode network of 337 speakers and 54 concepts
#> and 449 claim ties (8 parallel) from 2011-03-11 to 2011-04-01
#> # Transformed by exclusion: not tied at time 2011-04-01 (715 ties excluded)
#>
#> ── Nodes
#> # A tibble: 391 × 10
#> label mode active politician govt coalition office org party power
#> <chr> <chr> <lgl> <lgl> <lgl> <lgl> <lgl> <chr> <chr> <int>
#> 1 VfEW spea… TRUE FALSE FALSE NA FALSE VfEW NA 0
#> 2 Angela Merkel spea… TRUE TRUE TRUE TRUE TRUE CDU 31 2
#> 3 Sunday Times spea… TRUE FALSE FALSE NA FALSE Sund… NA 0
#> 4 SPD spea… TRUE TRUE FALSE FALSE FALSE SPD 32 1
#> 5 Norbert Rött… spea… TRUE TRUE TRUE TRUE TRUE CDU 31 1
#> 6 Torsten Krau… spea… TRUE FALSE FALSE NA FALSE Die … NA 0
#> # ℹ 385 more rows
#>
#> ── Ties
#> # A tibble: 449 × 5
#> from to time weight default
#> <int> <int> <date> <int> <lgl>
#> 1 1 338 2011-03-11 -1 FALSE
#> 2 2 339 2011-03-12 1 TRUE
#> 3 3 340 2011-03-13 -1 FALSE
#> 4 4 341 2011-03-13 1 TRUE
#> 5 2 342 2011-03-13 -1 TRUE
#> 6 5 343 2011-03-13 1 TRUE
#> # ℹ 443 more rows
#>
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
#>