These functions allow users to add and delete ties:
add_ties() adds additional ties to network data
delete_ties() deletes ties from network data
bind_ties() appends the tie data from two networks
filter_ties() subsets ties based on some tie attribute-related logical statement.
While add_*()/delete_*() functions operate similarly as comparable {igraph} functions,
filter*(), etc work like {tidyverse} or {dplyr}-style functions.
add_ties(.data, ties, attr_list = NULL)
delete_ties(.data, ties)
bind_ties(.data, ...)
filter_ties(.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
The ties to add. Several forms are accepted:
a single number, e.g. 3, in which case that number of ties
is added at random among those dyads not already tied
(respecting whether the network is directed or two-mode)
an even vector of node names or indices, e.g. c("Betty","Tina"),
interpreted pairwise as sender and receiver
a two-column matrix, edgelist, or data frame of node names or indices, each row of which is interpreted as a tie
an explicit tie formula in the same syntax as create_explicit(),
e.g. Betty -+ Tina or 1 -+ 3 for an arc from the first to the third
node, Betty +-+ Tina or 1 ++ 3 for both arcs, and
Betty -- Tina or 1 -- 3 for a tie between them.
Note that both ends of the tie operator must be marked with
- or +, so that 1-3 remains arithmetic while 1--3 is a tie.
Several ties can be added at once by wrapping them in c(),
e.g. c(Betty -+ Tina, Sue -+ Pam), and node sets can be linked
using :, e.g. Betty:Sue -+ Tina.
Such formulae can also be passed as one-sided formulas,
e.g. ~ Betty -+ Tina, which is useful when passing them around
programmatically.
Note that in a directed network an undirected tie operator, like an even vector, adds a single arc from the first to the second node.
A list of attributes to be added to the new ties. Where the network is weighted but no weight is given here, the new ties are given a weight of 1.
Additional parameters and arguments passed on internally.
A data object of the same class as the function was given.
Not all functions have methods available for all object classes. Below are the currently implemented S3 methods for these functions:
default igraph network stocnet tbl_graph
add_ties * * * *
bind_ties * * *
delete_ties * * * *
filter_ties * * * *If a method is not available for a particular class, but a default method is, the default method will attempt to coerce the object to a class for which a method is defined, and then coerce the output back to the original class. If no method is available for any class, an error will be thrown.
Other ties:
manip_ties_attr,
modif_direction,
modif_weight
Other manipulations:
manip_changes,
manip_global,
manip_info,
manip_nodes_attr,
manip_nodes_num,
manip_ties_attr
other <- create_filled(4) |> mutate(name = c("A", "B", "C", "D"))
mutate_ties(other, form = 1:6) |> filter_ties(form < 4)
#>
#> ── # Filled network ────────────────────────────────────────────────────────────
#> # A labelled, multiplex, undirected network of 4 nodes and 3 ties
#>
#> ── Nodes
#> # A tibble: 4 × 1
#> name
#> <chr>
#> 1 A
#> 2 B
#> 3 C
#> 4 D
#>
#> ── Ties
#> # A tibble: 3 × 3
#> from to form
#> <int> <int> <int>
#> 1 1 2 1
#> 2 1 3 2
#> 3 1 4 3
#>
add_tie_attribute(other, "weight", c(1, 2, 2, 2, 1, 2))
#> ── # Filled network ────────────────────────────────────────────────────────────
#> # A labelled, weighted, undirected network of 4 nodes and 6 ties
#>
#> ── Nodes
#> # A tibble: 4 × 1
#> name
#> <chr>
#> 1 A
#> 2 B
#> 3 C
#> 4 D
#>
#> ── Ties
#> # A tibble: 6 × 3
#> from to weight
#> <int> <int> <dbl>
#> 1 1 2 1
#> 2 1 3 2
#> 3 1 4 2
#> 4 2 3 2
#> 5 2 4 1
#> 6 3 4 2
#>
ison_adolescents |> add_ties(c("Betty","Tina"))
#> ── # The Adolescent Society ────────────────────────────────────────────────────
#> # A labelled, undirected network of 8 adolescents and 11 friendship ties
#>
#> ── Nodes
#> # A tibble: 8 × 1
#> name
#> <chr>
#> 1 Betty
#> 2 Sue
#> 3 Alice
#> 4 Jane
#> 5 Dale
#> 6 Pam
#> # ℹ 2 more rows
#>
#> ── Ties
#> # A tibble: 11 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 2 3
#> 3 3 4
#> 4 2 5
#> 5 3 5
#> 6 4 5
#> # ℹ 5 more rows
#>
ison_adolescents |> add_ties(Betty -+ Tina)
#> ── # The Adolescent Society ────────────────────────────────────────────────────
#> # A labelled, undirected network of 8 adolescents and 11 friendship ties
#>
#> ── Nodes
#> # A tibble: 8 × 1
#> name
#> <chr>
#> 1 Betty
#> 2 Sue
#> 3 Alice
#> 4 Jane
#> 5 Dale
#> 6 Pam
#> # ℹ 2 more rows
#>
#> ── Ties
#> # A tibble: 11 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 2 3
#> 3 3 4
#> 4 2 5
#> 5 3 5
#> 6 4 5
#> # ℹ 5 more rows
#>
ison_adolescents |> add_ties(c(Betty -+ Tina, Sue -+ Pam))
#> ── # The Adolescent Society ────────────────────────────────────────────────────
#> # A labelled, undirected network of 8 adolescents and 12 friendship ties
#>
#> ── Nodes
#> # A tibble: 8 × 1
#> name
#> <chr>
#> 1 Betty
#> 2 Sue
#> 3 Alice
#> 4 Jane
#> 5 Dale
#> 6 Pam
#> # ℹ 2 more rows
#>
#> ── Ties
#> # A tibble: 12 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 2 3
#> 3 3 4
#> 4 2 5
#> 5 3 5
#> 6 4 5
#> # ℹ 6 more rows
#>
ison_adolescents |> add_ties(3)
#> ── # The Adolescent Society ────────────────────────────────────────────────────
#> # A labelled, undirected network of 8 adolescents and 13 friendship ties
#>
#> ── Nodes
#> # A tibble: 8 × 1
#> name
#> <chr>
#> 1 Betty
#> 2 Sue
#> 3 Alice
#> 4 Jane
#> 5 Dale
#> 6 Pam
#> # ℹ 2 more rows
#>
#> ── Ties
#> # A tibble: 13 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 2 3
#> 3 3 4
#> 4 2 5
#> 5 3 5
#> 6 4 5
#> # ℹ 7 more rows
#>
delete_ties(ison_adolescents, 3)
#> ── # The Adolescent Society ────────────────────────────────────────────────────
#> # A labelled, undirected network of 8 adolescents and 9 friendship ties
#>
#> ── Nodes
#> # A tibble: 8 × 1
#> name
#> <chr>
#> 1 Betty
#> 2 Sue
#> 3 Alice
#> 4 Jane
#> 5 Dale
#> 6 Pam
#> # ℹ 2 more rows
#>
#> ── Ties
#> # A tibble: 9 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 2 3
#> 3 2 5
#> 4 3 5
#> 5 4 5
#> 6 2 6
#> # ℹ 3 more rows
#>
delete_ties(ison_adolescents, "Alice|Sue")
#> ── # The Adolescent Society ────────────────────────────────────────────────────
#> # A labelled, undirected network of 8 adolescents and 9 friendship ties
#>
#> ── Nodes
#> # A tibble: 8 × 1
#> name
#> <chr>
#> 1 Betty
#> 2 Sue
#> 3 Alice
#> 4 Jane
#> 5 Dale
#> 6 Pam
#> # ℹ 2 more rows
#>
#> ── Ties
#> # A tibble: 9 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 3 4
#> 3 2 5
#> 4 3 5
#> 5 4 5
#> 6 2 6
#> # ℹ 3 more rows
#>