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

Value

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)
#> $Betty
#> # The Adolescent Society
#> # A labelled, undirected network of 2 adolescents and 1 friendships ties
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 Betty
#> 2 Sue  
#> # A tibble: 1 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 
#> $Sue
#> # The Adolescent Society
#> # A labelled, undirected network of 5 adolescents and 6 friendships ties
#> # A tibble: 5 × 1
#>   name 
#>   <chr>
#> 1 Betty
#> 2 Sue  
#> 3 Alice
#> 4 Dale 
#> 5 Pam  
#> # A tibble: 6 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     2     3
#> 3     2     4
#> 4     3     4
#> 5     2     5
#> 6     3     5
#> 
#> $Alice
#> # The Adolescent Society
#> # A labelled, undirected network of 5 adolescents and 7 friendships ties
#> # A tibble: 5 × 1
#>   name 
#>   <chr>
#> 1 Sue  
#> 2 Alice
#> 3 Jane 
#> 4 Dale 
#> 5 Pam  
#> # A tibble: 7 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     2     3
#> 3     1     4
#> 4     2     4
#> 5     3     4
#> 6     1     5
#> # ℹ 1 more row
#> 
#> $Jane
#> # The Adolescent Society
#> # A labelled, undirected network of 3 adolescents and 3 friendships ties
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 Alice
#> 2 Jane 
#> 3 Dale 
#> # A tibble: 3 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     1     3
#> 3     2     3
#> 
#> $Dale
#> # The Adolescent Society
#> # A labelled, undirected network of 4 adolescents and 5 friendships ties
#> # A tibble: 4 × 1
#>   name 
#>   <chr>
#> 1 Sue  
#> 2 Alice
#> 3 Jane 
#> 4 Dale 
#> # A tibble: 5 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     2     3
#> 3     1     4
#> 4     2     4
#> 5     3     4
#> 
#> $Pam
#> # The Adolescent Society
#> # A labelled, undirected network of 4 adolescents and 4 friendships ties
#> # A tibble: 4 × 1
#>   name 
#>   <chr>
#> 1 Sue  
#> 2 Alice
#> 3 Pam  
#> 4 Carol
#> # A tibble: 4 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     1     3
#> 3     2     3
#> 4     3     4
#> 
#> $Carol
#> # The Adolescent Society
#> # A labelled, undirected network of 3 adolescents and 2 friendships ties
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 Pam  
#> 2 Carol
#> 3 Tina 
#> # A tibble: 2 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     2     3
#> 
#> $Tina
#> # The Adolescent Society
#> # A labelled, undirected network of 2 adolescents and 1 friendships ties
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 Carol
#> 2 Tina 
#> # A tibble: 1 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 
  # graphs(to_egos(ison_adolescents,2))
ison_adolescents %>%
  mutate(unicorn = sample(c("yes", "no"), 8,
                          replace = TRUE)) %>%
  to_subgraphs(attribute = "unicorn")
#> [[1]]
#> # The Adolescent Society
#> # A labelled, undirected network of 4 adolescents and 1 friendships ties
#> # A tibble: 4 × 2
#>   name  unicorn
#>   <chr> <chr>  
#> 1 Betty yes    
#> 2 Jane  yes    
#> 3 Dale  yes    
#> 4 Pam   yes    
#> # A tibble: 1 × 2
#>    from    to
#>   <int> <int>
#> 1     2     3
#> 
#> [[2]]
#> # The Adolescent Society
#> # A labelled, undirected network of 4 adolescents and 2 friendships ties
#> # A tibble: 4 × 2
#>   name  unicorn
#>   <chr> <chr>  
#> 1 Sue   no     
#> 2 Alice no     
#> 3 Carol no     
#> 4 Tina  no     
#> # A tibble: 2 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     3     4
#> 
  to_components(ison_marvel_relationships)
#> [[1]]
#> # A labelled, complex, signed, undirected network of 50 nodes and 558 ties
#> # A tibble: 50 × 10
#>   name     Gender Appearances Attractive  Rich Intellect Omnilingual PowerOrigin
#>   <chr>    <chr>        <int>      <int> <int>     <int>       <int> <chr>      
#> 1 Abomina… Male           427          0     0         1           1 Radiation  
#> 2 Ant-Man  Male           589          1     0         1           0 Human      
#> 3 Apocaly… Male          1207          0     0         1           1 Mutant     
#> 4 Beast    Male          7609          1     0         1           0 Mutant     
#> 5 Black P… Male          2189          1     1         1           0 Human      
#> 6 Black W… Female        2907          1     0         1           0 Human      
#> # ℹ 44 more rows
#> # ℹ 2 more variables: UnarmedCombat <int>, ArmedCombat <int>
#> # A tibble: 558 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     4    -1
#> 2     1    10    -1
#> 3     1    11    -1
#> 4     1    22    -1
#> 5     1    23    -1
#> 6     1    24    -1
#> # ℹ 552 more rows
#> 
#> [[2]]
#> # A labelled, signed, undirected network of 1 nodes and 0 ties
#> # A tibble: 1 × 10
#>   name  Gender Appearances Attractive  Rich Intellect Omnilingual PowerOrigin
#>   <chr> <chr>        <int>      <int> <int>     <int>       <int> <chr>      
#> 1 Cable Male          2734          0     0         1           0 Mutant     
#> # ℹ 2 more variables: UnarmedCombat <int>, ArmedCombat <int>
#> # A tibble: 0 × 3
#> # ℹ 3 variables: from <int>, to <int>, sign <dbl>
#> 
#> [[3]]
#> # A labelled, signed, undirected network of 1 nodes and 0 ties
#> # A tibble: 1 × 10
#>   name     Gender Appearances Attractive  Rich Intellect Omnilingual PowerOrigin
#>   <chr>    <chr>        <int>      <int> <int>     <int>       <int> <chr>      
#> 1 Iron Fi… Male          1789          0     1         1           0 Human      
#> # ℹ 2 more variables: UnarmedCombat <int>, ArmedCombat <int>
#> # A tibble: 0 × 3
#> # ℹ 3 variables: from <int>, to <int>, sign <dbl>
#> 
#> [[4]]
#> # A labelled, signed, undirected network of 1 nodes and 0 ties
#> # A tibble: 1 × 10
#>   name     Gender Appearances Attractive  Rich Intellect Omnilingual PowerOrigin
#>   <chr>    <chr>        <int>      <int> <int>     <int>       <int> <chr>      
#> 1 Luke Ca… Male          2466          0     0         0           0 Human      
#> # ℹ 2 more variables: UnarmedCombat <int>, ArmedCombat <int>
#> # A tibble: 0 × 3
#> # ℹ 3 variables: from <int>, to <int>, sign <dbl>
#> 
ison_adolescents %>%
  mutate_ties(wave = sample(1995:1998, 10, replace = TRUE)) %>%
  to_waves(attribute = "wave")
#> $`1995`
#> # The Adolescent Society
#> # A longitudinal, labelled, undirected network of 8 adolescents and 1
#> friendships ties
#> # A tibble: 8 × 1
#>   name 
#>   <chr>
#> 1 Betty
#> 2 Sue  
#> 3 Alice
#> 4 Jane 
#> 5 Dale 
#> 6 Pam  
#> # ℹ 2 more rows
#> # A tibble: 1 × 3
#>    from    to  wave
#>   <int> <int> <int>
#> 1     6     7  1995
#> 
#> $`1996`
#> # The Adolescent Society
#> # A longitudinal, labelled, undirected network of 8 adolescents and 6
#> friendships ties
#> # A tibble: 8 × 1
#>   name 
#>   <chr>
#> 1 Betty
#> 2 Sue  
#> 3 Alice
#> 4 Jane 
#> 5 Dale 
#> 6 Pam  
#> # ℹ 2 more rows
#> # A tibble: 6 × 3
#>    from    to  wave
#>   <int> <int> <int>
#> 1     2     3  1996
#> 2     2     5  1996
#> 3     3     5  1996
#> 4     4     5  1996
#> 5     3     6  1996
#> 6     7     8  1996
#> 
#> $`1997`
#> # The Adolescent Society
#> # A longitudinal, labelled, undirected network of 8 adolescents and 3
#> friendships ties
#> # A tibble: 8 × 1
#>   name 
#>   <chr>
#> 1 Betty
#> 2 Sue  
#> 3 Alice
#> 4 Jane 
#> 5 Dale 
#> 6 Pam  
#> # ℹ 2 more rows
#> # A tibble: 3 × 3
#>    from    to  wave
#>   <int> <int> <int>
#> 1     1     2  1997
#> 2     3     4  1997
#> 3     2     6  1997
#> 
ison_adolescents %>%
  mutate_ties(time = 1:10, increment = 1) %>% 
  add_ties(c(1,2), list(time = 3, increment = -1)) %>% 
  to_slices(slice = 7)
#> # A labelled, weighted, undirected network of 8 nodes and 6 ties
#> # A tibble: 8 × 1
#>   name 
#>   <chr>
#> 1 Betty
#> 2 Sue  
#> 3 Alice
#> 4 Jane 
#> 5 Dale 
#> 6 Pam  
#> # ℹ 2 more rows
#> # A tibble: 6 × 3
#>    from    to weight
#>   <int> <int>  <dbl>
#> 1     2     3      1
#> 2     3     4      1
#> 3     2     5      1
#> 4     3     5      1
#> 5     4     5      1
#> 6     2     6      1