manip_split function

Splitting networks into lists

Splitting networks into lists

These functions offer tools for splitting manynet-consistent objects (matrices, igraph, tidygraph, or network objects) into lists of networks.

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

data.framediff_modeligraphmatrixnetworktbl_graph
to_components101111
to_egos101111
to_slices001001
to_subgraphs001011
to_waves111001
to_egos(.data, max_dist = 1, min_dist = 0, direction = c("out", "in")) to_subgraphs(.data, attribute) to_components(.data) to_waves(.data, attribute = "wave", panels = NULL, cumulative = FALSE) to_slices(.data, attribute = "time", slice = 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
  • max_dist: The maximum breadth of the neighbourhood. By default 1.

  • min_dist: The minimum breadth of the neighbourhood. By default 0. Increasing this to 1 excludes the ego, and 2 excludes ego's direct alters.

  • direction: String, either "out" or "in".

  • attribute: One or two attributes used to slice data.

  • panels: Would you like to select certain waves? NULL by default. That is, a list of networks for every available wave is returned. Users can also list specific waves they want to select.

  • cumulative: Whether to make wave ties cumulative. FALSE by default. That is, each wave is treated isolated.

  • slice: Character string or character list indicating the date(s) or integer(s) range used to slice data (e.g slice = c(1:2, 3:4)).

Returns

The returned object will be a list of network objects.

Functions

  • to_egos(): Returns a list of ego (or focal) networks.
  • to_subgraphs(): Returns a list of subgraphs on some given node attribute.
  • to_components(): Returns a list of the components in a network.
  • to_waves(): Returns a network with some discrete observations over time into a list of those observations.
  • to_slices(): Returns a list of a network with some continuous time variable at some time slice(s).

Examples

to_egos(ison_adolescents) # graphs(to_egos(ison_adolescents,2)) ison_adolescents %>% mutate(unicorn = sample(c("yes", "no"), 8, replace = TRUE)) %>% to_subgraphs(attribute = "unicorn") to_components(ison_marvel_relationships) ison_adolescents %>% mutate_ties(wave = sample(1995:1998, 10, replace = TRUE)) %>% to_waves(attribute = "wave") ison_adolescents %>% mutate_ties(time = 1:10, increment = 1) %>% add_ties(c(1,2), list(time = 3, increment = -1)) %>% to_slices(slice = 7)

See Also

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

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