comp_ply() applies a function, that uses an alter attribute to calculate
a compositional measurement, on all networks in an egor object and returns a
numeric vector.
Arguments
- object
An
egorobject.- alt.attr
A
characternaming the variable containing the alter-attribute.- .f
A
functionthat returns a numeric.- ...
Optional arguments to
.f.- ego.attr
Optional
characternaming an ego attribute.- result.name
Optional
characternaming the result column.
Details
When an ego attribute is used the .f is called like this:
.f(alt.attr, ego.attr, ...). .f must return a single numeric value.
Examples
df <- make_egor(10, 32)
comp_ply(df, "age.years", sd, na.rm = TRUE)
#> # A tibble: 10 × 2
#> .egoID result
#> <dbl> <dbl>
#> 1 1 28.9
#> 2 2 28.1
#> 3 3 27.0
#> 4 4 26.8
#> 5 5 23.5
#> 6 6 28.2
#> 7 7 26.9
#> 8 8 28.6
#> 9 9 28.7
#> 10 10 28.1