These functions offer ways to modify data held about how nodes change over time. They include:
add_changes()
adds a table of changes to the nodes of a network.
mutate_changes()
can be used to update network changes.
filter_changes()
is used to subset network changes.
collect_changes()
is similar to filter_changes()
,
but collects the cumulative changes up to a time point.
apply_changes()
applies the changes collected up to a time point
to a network, removing the changes.
An example of when this might be useful is to track change in the composition of a network (when nodes are present or absent over time), though the function can flexibly accommodate changes in other nodal attributes.
add_changes(.data, changes)
mutate_changes(.data, ...)
filter_changes(.data, ..., .by = NULL)
select_changes(.data, ..., .by = NULL)
collect_changes(.data, time)
apply_changes(.data, time)
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
A data frame of changes. Ideally this will be in the form of "wave", "node", "var", and "value", but there are internal routines from some otherwise common formats. A data frame of composition change can be just two columns.
Additional arguments.
An attribute name to join objects by. By default, NULL.
A time point or wave at which to present the network.
add_changes(ison_algebra,
data.frame(wave = 2, node = 1, var = "active", value = FALSE))
#>
#> ── # M182 Algebra Class ────────────────────────────────────────────────────────
#> # A multiplex, weighted, directed network of 16 nodes and 279 social, tasks,
#> and friends arcs
#>
#> ── Nodes
#> # A tibble: 16 × 1
#> active
#> <lgl>
#> 1 TRUE
#> 2 TRUE
#> 3 TRUE
#> 4 TRUE
#> # ℹ 12 more rows
#>
#> ── Changes
#> # A tibble: 1 × 4
#> wave node var value
#> <dbl> <dbl> <chr> <lgl>
#> 1 2 1 active FALSE
#>
#> ── Ties
#> # A tibble: 279 × 4
#> from to type weight
#> <int> <int> <chr> <dbl>
#> 1 1 5 social 1.2
#> 2 1 5 tasks 0.3
#> 3 1 8 social 0.15
#> 4 1 9 social 2.85
#> # ℹ 275 more rows
#>
filter_changes(fict_starwars, node == "Anakin")
#> ── # Star Wars network data ────────────────────────────────────────────────────
#> # A longitudinal, labelled, complex, weighted, directed network of 110
#> characters and 563 interaction arcs over 7 waves
#>
#> ── Nodes
#> # A tibble: 110 × 12
#> name species homeworld sex height hair_color eye_color skin_color
#> <chr> <chr> <chr> <chr> <int> <chr> <chr> <chr>
#> 1 Admiral Ackbar Mon Ca… Mon Cala male 180 none orange brown mot…
#> 2 Admiral Statura Human Garel male 172 black brown light
#> 3 Anakin Human Tatooine male 188 blond blue fair
#> 4 Bail Organa Human Alderaan male 191 black brown tan
#> # ℹ 106 more rows
#> # ℹ 4 more variables: birth_year <dbl>, mass <dbl>, faction <chr>, active <lgl>
#>
#> ── Changes
#> # A tibble: 0 × 4
#> # ℹ 4 variables: time <int>, node <int>, var <chr>, value <chr>
#>
#> ── Ties
#> # A tibble: 563 × 4
#> from to weight wave
#> <int> <int> <int> <int>
#> 1 80 73 11 1
#> 2 80 79 14 1
#> 3 80 3 16 1
#> 4 80 106 3 1
#> # ℹ 559 more rows
#>
select_changes(fict_starwars, node)
#> ── # Star Wars network data ────────────────────────────────────────────────────
#> # A longitudinal, labelled, complex, weighted, directed network of 110
#> characters and 563 interaction arcs over 7 waves
#>
#> ── Nodes
#> # A tibble: 110 × 12
#> name species homeworld sex height hair_color eye_color skin_color
#> <chr> <chr> <chr> <chr> <int> <chr> <chr> <chr>
#> 1 Admiral Ackbar Mon Ca… Mon Cala male 180 none orange brown mot…
#> 2 Admiral Statura Human Garel male 172 black brown light
#> 3 Anakin Human Tatooine male 188 blond blue fair
#> 4 Bail Organa Human Alderaan male 191 black brown tan
#> # ℹ 106 more rows
#> # ℹ 4 more variables: birth_year <dbl>, mass <dbl>, faction <chr>, active <lgl>
#>
#> ── Changes
#> # A tibble: 184 × 1
#> node
#> <int>
#> 1 7
#> 2 10
#> 3 11
#> 4 13
#> # ℹ 180 more rows
#>
#> ── Ties
#> # A tibble: 563 × 4
#> from to weight wave
#> <int> <int> <int> <int>
#> 1 80 73 11 1
#> 2 80 79 14 1
#> 3 80 3 16 1
#> 4 80 106 3 1
#> # ℹ 559 more rows
#>
collect_changes(fict_starwars, time = 3)
#> # A tibble: 59 × 3
#> # Groups: node, var [59]
#> node var value
#> <int> <chr> <chr>
#> 1 3 eye_color yellow
#> 2 3 faction Sith
#> 3 3 hair_color none
#> 4 3 height 202
#> 5 3 mass 136
#> 6 3 skin_color white
#> 7 7 active FALSE
#> 8 10 active FALSE
#> 9 11 active FALSE
#> 10 13 active FALSE
#> # ℹ 49 more rows
collect_changes(fict_starwars, time = 3)
#> # A tibble: 59 × 3
#> # Groups: node, var [59]
#> node var value
#> <int> <chr> <chr>
#> 1 3 eye_color yellow
#> 2 3 faction Sith
#> 3 3 hair_color none
#> 4 3 height 202
#> 5 3 mass 136
#> 6 3 skin_color white
#> 7 7 active FALSE
#> 8 10 active FALSE
#> 9 11 active FALSE
#> 10 13 active FALSE
#> # ℹ 49 more rows