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)

Arguments

object

An egor object.

alt.attr

A character naming the variable containing the alter-attribute.

.f

A function that returns a numeric.

...

Optional arguments to .f.

ego.attr

Optional character naming an ego attribute.

Value

A tibble with the ego ID and a numeric result vector.

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 x 2 #> .egoID result #> <chr> <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