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
.
comp_ply(object, alt.attr, .f, ..., ego.attr = NULL, result.name = "result")
An egor
object.
A character
naming the variable containing the alter-attribute.
A function
that returns a numeric.
Optional arguments to .f
.
Optional character
naming an ego attribute.
Optional character
naming the result column.
A tibble
with the ego ID and a numeric
result vector.
When an ego attribute is used the .f
is called like this:
.f(alt.attr, ego.attr, ...)
. .f
must return a single numeric value.
df <- make_egor(10, 32)
comp_ply(df, "age.years", sd, na.rm = TRUE)
#> # A tibble: 10 × 2
#> .egoID result
#> <dbl> <dbl>
#> 1 1 26.6
#> 2 2 26.2
#> 3 3 26.3
#> 4 4 26.1
#> 5 5 26.4
#> 6 6 26.0
#> 7 7 26.0
#> 8 8 25.2
#> 9 9 26.4
#> 10 10 26.4