These functions allow users to add and delete nodes and their attributes:
add_nodes()
adds an additional number of nodes to network data.
delete_nodes()
deletes nodes from network data.
add_node_attribute()
, mutate()
, or mutate_nodes()
offer ways to add
a vector of values to a network as a nodal attribute.
rename_nodes()
and rename()
rename nodal attributes.
bind_node_attributes()
appends all nodal attributes from one network to another,
and join_nodes()
merges all nodal attributes from one network to another.
filter_nodes()
subsets nodes based on some nodal attribute-related logical statement.
Note that while add_*()
/delete_*()
functions operate similarly as comparable {igraph}
functions,
mutate*()
, bind*()
, etc work like {tidyverse}
or {dplyr}
-style functions.
add_nodes(.data, nodes, attribute = NULL)
delete_nodes(.data, nodes)
add_node_attribute(.data, attr_name, vector)
mutate_nodes(.data, ...)
mutate(.data, ...)
bind_node_attributes(.data, object2)
join_nodes(
.data,
object2,
.by = NULL,
join_type = c("full", "left", "right", "inner")
)
rename_nodes(.data, ...)
rename(.data, ...)
filter_nodes(.data, ..., .by)
An object of a manynet-consistent class:
matrix (adjacency or incidence) from {base}
R
edgelist, a data frame from {base}
R or tibble from {tibble}
igraph, from the {igraph}
package
network, from the {network}
package
tbl_graph, from the {tidygraph}
package
The number of nodes to be added.
A named list to be added as tie or node attributes.
Name of the new attribute in the resulting object.
A vector of values for the new attribute.
Additional arguments.
A second object to copy nodes or ties from.
An attribute name to join objects by. By default, NULL.
A type of join to be used. Options are "full","left", "right", "inner".
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:
igraph | network | tbl_graph | |
add_nodes | 1 | 1 | 1 |
delete_nodes | 1 | 1 | 1 |
Other modifications:
manip_as
,
manip_correlation
,
manip_deformat
,
manip_from
,
manip_levels
,
manip_miss
,
manip_paths
,
manip_permutation
,
manip_preformat
,
manip_project
,
manip_reformat
,
manip_scope
,
manip_split
,
manip_ties
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
#> # A tibble: 8 × 1
#> name
#> <chr>
#> 1 A
#> 2 B
#> 3 C
#> 4 D
#> 5 Matthew
#> 6 Mark
#> # ℹ 2 more rows
#> # 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
other <- create_filled(4) %>% mutate(name = c("A", "B", "C", "D"))
another <- create_filled(3) %>% mutate(name = c("E", "F", "G"))
join_nodes(another, other)
#> Joining with `by = join_by(name)`
#> # Filled network
#> # A labelled, undirected network of 7 nodes and 3 ties
#> # A tibble: 7 × 1
#> name
#> <chr>
#> 1 E
#> 2 F
#> 3 G
#> 4 A
#> 5 B
#> 6 C
#> # ℹ 1 more row
#> # A tibble: 3 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 3
#> 3 2 3