These functions allow users to add and delete nodes:

  • add_nodes() adds an additional number of nodes to network data.

  • delete_nodes() deletes nodes from network data.

  • delete_isolates() deletes all nodes without ties.

  • delete_incomplete() deletes nodes with any missing attribute values, retaining only the complete cases. A node attribute that is missing for every node is not read as missing data, since in a dynamic network such an attribute is a placeholder for one whose values are all recorded as changes.

  • bind_nodes() adds two nodesets together.

  • filter_nodes() subsets nodes based on some nodal attribute-related logical statement.

  • arrange_nodes() reorders nodes based on some nodal attribute.

While add_*()/delete_*() functions operate similarly as comparable {igraph} functions, bind_*() and filter_*() works like a {tidyverse} or {dplyr}-style function.

add_nodes(.data, nodes, attribute = NULL)

delete_nodes(.data, nodes)

delete_isolates(.data)

delete_incomplete(.data)

bind_nodes(.data, object2)

filter_nodes(.data, ..., .by = NULL)

arrange_nodes(.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

nodes

The number of nodes to be added.

attribute

A named list to be added as tie or node attributes.

object2

A second object to copy nodes or ties from.

...

Additional parameters and arguments passed on internally.

.by

An attribute name to join objects by. By default, NULL.

Value

A data object of the same class as the function was given.

Details

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

                  data.frame default igraph list matrix network stocnet
add_nodes                          *      *                   *
arrange_nodes                      *                                  *
bind_nodes                         *                                  *
delete_incomplete                  *                                  *
delete_isolates            *       *      *    *      *       *       *
delete_nodes                       *      *                   *
filter_nodes                       *                                  *
                  tbl_graph
add_nodes                 *
arrange_nodes             *
bind_nodes
delete_incomplete         *
delete_isolates           *
delete_nodes              *
filter_nodes              *

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.

Examples

  other <- create_filled(4) |> mutate(name = c("A", "B", "C", "D"))
  add_nodes(other, 4, list(name = c("Matthew", "Mark", "Luke", "Tim")))
#> 
#> ── # Filled network ────────────────────────────────────────────────────────────
#> # A labelled, undirected network of 8 nodes and 6 ties
#> 
#> ── Nodes 
#> # A tibble: 8 × 1
#>   name   
#>   <chr>  
#> 1 A      
#> 2 B      
#> 3 C      
#> 4 D      
#> 5 Matthew
#> 6 Mark   
#> # ℹ 2 more rows
#> 
#> ── Ties 
#> # A tibble: 6 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     1     3
#> 3     1     4
#> 4     2     3
#> 5     2     4
#> 6     3     4
#> 
ison_adolescents |>
  mutate_ties(wave = sample(1995:1998, 10, replace = TRUE)) |>
  to_waves(attribute = "wave") |>
  delete_isolates()
#> $`1995`
#> # A longitudinal, labelled, undirected network of 3 nodes and 2 ties over 1
#> waves
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 Sue  
#> 2 Alice
#> 3 Dale 
#> 
#> ── Ties 
#> # A tibble: 2 × 3
#>    from    to  wave
#>   <int> <int> <int>
#> 1     1     2  1995
#> 2     1     3  1995
#> 
#> 
#> $`1996`
#> # A longitudinal, labelled, undirected network of 2 nodes and 1 ties over 1
#> waves
#> 
#> ── Nodes 
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 Betty
#> 2 Sue  
#> 
#> ── Ties 
#> # A tibble: 1 × 3
#>    from    to  wave
#>   <int> <int> <int>
#> 1     1     2  1996
#> 
#> 
#> $`1997`
#> # A longitudinal, labelled, undirected network of 4 nodes and 3 ties over 1
#> waves
#> 
#> ── Nodes 
#> # A tibble: 4 × 1
#>   name 
#>   <chr>
#> 1 Sue  
#> 2 Alice
#> 3 Dale 
#> 4 Pam  
#> 
#> ── Ties 
#> # A tibble: 3 × 3
#>    from    to  wave
#>   <int> <int> <int>
#> 1     2     3  1997
#> 2     1     4  1997
#> 3     2     4  1997
#> 
#> 
#> $`1998`
#> # A longitudinal, labelled, undirected network of 6 nodes and 4 ties over 1
#> waves
#> 
#> ── Nodes 
#> # A tibble: 6 × 1
#>   name 
#>   <chr>
#> 1 Alice
#> 2 Jane 
#> 3 Dale 
#> 4 Pam  
#> 5 Carol
#> 6 Tina 
#> 
#> ── Ties 
#> # A tibble: 4 × 3
#>    from    to  wave
#>   <int> <int> <int>
#> 1     1     2  1998
#> 2     2     3  1998
#> 3     4     5  1998
#> 4     5     6  1998
#> 
#>