Learn R Programming

manynet (version 0.1.1)

split: Tools for splitting networks, graphs, and matrices into lists

Description

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

Usage

to_egos(.data, max_dist = 1, min_dist = 0)

to_subgraphs(.data, attribute)

to_components(.data)

to_waves(.data, attribute = "wave", panels = NULL)

to_slices(.data, attribute = "time", slice = NULL)

Value

The returned object will be a list of network objects.

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.

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.

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)).

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).

See Also

Other manipulations: add, from, miss, reformat, tidy, transform()

Examples

Run this code
  to_egos(ison_adolescents)
  autographs(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(wave = sample(1995:1998, 10, replace = TRUE)) %>%
  to_waves(attribute = "wave", panels = c(1995, 1996))
ison_adolescents %>%
  mutate_ties(time = 1:10, increment = 1) %>% 
  add_ties(c(1,2), list(time = 3, increment = -1)) %>% 
  to_slices(slice = 7)

Run the code above in your browser using DataLab