manip_preformat function

Modifying network formats

Modifying network formats

These functions add some format to manynet-consistent data.

  • to_directed() reformats undirected network data to a directed network.
  • to_redirected() reformats the direction of directed network data, flipping any existing direction.
  • to_reciprocated() reformats directed network data such that every directed tie is reciprocated.
  • to_acyclic() reformats network data to an acyclic graph.
  • to_named() reformats unlabelled network data to labelled network data from a vector of names or random baby names.
  • to_signed() reformats unsigned network data to signed network data with signs from a mark vector or at random.

If the format condition is not met, for example to_undirected() is used on a network that is already undirected, the network data is returned unaltered. No warning is given so that these functions can be used to ensure conformance.

Unlike the as_*() group of functions, these functions always return the same class as they are given, only transforming these objects' properties.

to_named(.data, names = NULL) to_signed(.data, mark = NULL) to_weighted(.data, measure = NULL)

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
  • names: Character vector of the node names. NULL by default.

  • mark: A mark (logical vector) the length of the ties in the network.

  • measure: A numeric vector (measure) that will be added as the tie weights to the network. If this is NULL, then the tie weights will be drawn from a Poisson distribution with λ=4\lambda = 4.

Returns

All to_ functions return an object of the same class as that provided. So passing it an igraph object will return an igraph object and passing it a network object will return a network object, with certain modifications as outlined for each function.

Details

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

data.frameigraphmatrixnetworktbl_graph
to_acyclic11111
to_directed11111
to_named11111
to_reciprocated11111
to_redirected11111
to_simplex01101

See Also

Other modifications: manip_as, manip_correlation, manip_deformat, manip_from, manip_levels, manip_miss, manip_nodes, manip_paths, manip_permutation, manip_project, manip_reformat, manip_scope, manip_split, manip_ties

  • Maintainer: James Hollway
  • License: MIT + file LICENSE
  • Last published: 2024-11-05