add_nodes {manynet}R Documentation

Modifying node data

Description

These functions allow users to add and delete nodes and their attributes:

Note that while ⁠add_*()⁠/⁠delete_*()⁠ functions operate similarly as comparable {igraph} functions, ⁠mutate*()⁠, ⁠bind*()⁠, etc work like {tidyverse} or {dplyr}-style functions.

Usage

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)

Arguments

.data

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

nodes

The number of nodes to be added.

attribute

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

attr_name

Name of the new attribute in the resulting object.

vector

A vector of values for the new attribute.

...

Additional arguments.

object2

A second object to copy nodes or ties from.

.by

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

join_type

A type of join to be used. Options are "full","left", "right", "inner".

Details

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 0 0

Value

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

See Also

Other modifications: add_ties(), as(), correlation, from, miss, reformat, split(), to_levels, to_paths, to_project, to_scope

Examples

  other <- create_filled(4) %>% mutate(name = c("A", "B", "C", "D"))
  add_nodes(other, 4, list(name = c("Matthew", "Mark", "Luke", "Tim")))
  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)

[Package manynet version 1.0.2 Index]