Apply a function along edges within a pfc
object
pf_edge_apply.Rd
Features of the returned pfc
will be the output of the function applied
to the original features. Therefore the functionm provided must return a
vector the same length of the input.
Arguments
- x
A
pfc
object- fun
A function to apply to the edge vectors, which will be passed as the first argument. Must return a vector the same length and type as the input.
- ...
Any additional arguments to pass to
fun
Examples
## average features of descendents of each edge as a pfc:
pf_edge_apply(pf_desc(pf_indexes(rpfc(100))), function(x) rep(mean(x), length(x)))
#> <pfc<e:198>[198]>
#> First 10 phylogenetic flows:
#> [1] ◎── 3.4──→ Node4 ── 5.7──→ Node6 ── 7.0──→ Node27
#>
#> [2] ◎── 3.4──→ Node4 ── 5.7──→ Node6 ── 7.0──→ Node27 ── 9.3──→ Node30 ── 11.9──→ Node44 ── 13.2──→ Node82
#>
#> [3] ◎── 3.4──→ Node4 ── 5.7──→ Node6 ── 7.0──→ Node27 ── 9.3──→ Node30 ── 11.9──→ Node44 ── 13.2──→ Node82 ── 15.8──→ Node84 ── 17.5──→ Node89
#>
#> [4] ◎── 3.4──→ Node4 ── 5.7──→ Node6 ── 7.0──→ Node27 ── 9.3──→ Node30 ── 11.9──→ Node44 ── 13.2──→ Node82 ── 15.8──→ Node84 ── 17.5──→ Node89
#>
#> [5] ◎── 3.4──→ Node4 ── 5.7──→ Node6 ── 7.0──→ Node27 ── 9.3──→ Node30 ── 11.9──→ Node44 ── 13.2──→ Node82 ── 15.8──→ Node84
#>
#> [6] ◎── 3.4──→ Node4 ── 5.7──→ Node6 ── 7.0──→ Node27 ── 9.3──→ Node30 ── 11.9──→ Node44
#>
#> [7] ◎── 3.4──→ Node4 ── 5.7──→ Node6 ── 7.0──→ Node27 ── 9.3──→ Node30 ── 19.4──→ Node40 ── 21.4──→ Node55 ── 23.5──→ Node75
#>
#> [8] ◎── 3.4──→ Node4 ── 5.7──→ Node6 ── 7.0──→ Node27 ── 9.3──→ Node30 ── 19.4──→ Node40 ── 21.4──→ Node55 ── 23.5──→ Node75
#>
#> [9] ◎── 3.4──→ Node4 ── 5.7──→ Node6 ── 7.0──→ Node27 ── 9.3──→ Node30 ── 19.4──→ Node40 ── 21.4──→ Node55 ── 25.2──→ Node74
#>
#> [10] ◎── 3.4──→ Node4 ── 5.7──→ Node6 ── 7.0──→ Node27 ── 9.3──→ Node30 ── 19.4──→ Node40 ── 21.4──→ Node55 ── 25.2──→ Node74 ── 27.5──→ Node97