Count attribute combinations of dyads in ego-centered networks
Source:R/count_dyads.R
count_dyads.Rd
count_dyads()
counts the attribute combinations of alter-alter ties/ dyads
in ego-centered networks. The results can be returned as a wide or long
tibble
/ data.frame
.
Usage
count_dyads(
object,
alter_var_name,
return_as = c("wide", "long"),
prefix = NULL
)
Arguments
- object
An
egor
object.- alter_var_name
Character
, naming the alter variable to use as attribute.- return_as
Character
, either "wide" (default) or "long".- prefix
Character
, added in front of variables. Only used ifreturn_as
is "wide". IfNULL
(default) prefix is automatically generated.
Examples
data(egor32)
count_dyads(object = egor32,
alter_var_name = "country")
#> # A tibble: 32 × 11
#> .egoID dy_cou_Australia_Austr…¹ dy_cou_Australia_Ger…² dy_cou_Australia_Pol…³
#> <dbl> <int> <int> <int>
#> 1 1 2 6 3
#> 2 2 0 2 0
#> 3 3 4 6 4
#> 4 4 1 1 1
#> 5 5 2 11 4
#> 6 6 2 1 1
#> 7 7 0 5 7
#> 8 8 1 7 1
#> 9 9 1 6 4
#> 10 10 0 3 1
#> # ℹ 22 more rows
#> # ℹ abbreviated names: ¹dy_cou_Australia_Australia, ²dy_cou_Australia_Germany,
#> # ³dy_cou_Australia_Poland
#> # ℹ 7 more variables: dy_cou_Australia_USA <int>, dy_cou_Germany_Germany <int>,
#> # dy_cou_Germany_Poland <int>, dy_cou_Germany_USA <int>,
#> # dy_cou_Poland_USA <int>, dy_cou_USA_USA <int>, dy_cou_Poland_Poland <int>
# Return result as long tibble.
count_dyads(object = egor32,
alter_var_name = "country",
return_as = "long")
#> # A tibble: 278 × 3
#> .egoID dyads n
#> <dbl> <chr> <int>
#> 1 1 Australia_Australia 2
#> 2 1 Australia_Germany 6
#> 3 1 Australia_Poland 3
#> 4 1 Australia_USA 3
#> 5 1 Germany_Germany 3
#> 6 1 Germany_Poland 4
#> 7 1 Germany_USA 6
#> 8 1 Poland_USA 2
#> 9 1 USA_USA 3
#> 10 2 Australia_Germany 2
#> # ℹ 268 more rows