Skip to contents

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.

Usage

pf_edge_apply(x, fun, ...)

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

Value

A pfc object with the same structure as x but with features replaced with the output of 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.8──→ Node3 ──  5.9──→ Node5 ──  7.5──→ Node7 ──  9.7──→ Node14 ── 11.2──→ Node26 ── 13.5──→ Node96 
#> 
#> [2] ◎──  3.8──→ Node3 ──  5.9──→ Node5 ──  7.5──→ Node7 ──  9.7──→ Node14 ── 11.2──→ Node26 ── 13.5──→ Node96 
#> 
#> [3] ◎──  3.8──→ Node3 ──  5.9──→ Node5 ──  7.5──→ Node7 ──  9.7──→ Node14 ── 11.2──→ Node26 ── 15.2──→ Node29 ── 17.5──→ Node60 
#> 
#> [4] ◎──  3.8──→ Node3 ──  5.9──→ Node5 ──  7.5──→ Node7 ──  9.7──→ Node14 ── 11.2──→ Node26 ── 15.2──→ Node29 ── 17.5──→ Node60 
#> 
#> [5] ◎──  3.8──→ Node3 ──  5.9──→ Node5 ──  7.5──→ Node7 ──  9.7──→ Node14 ── 11.2──→ Node26 ── 15.2──→ Node29 ── 19.3──→ Node36 ── 21.5──→ Node40 
#> 
#> [6] ◎──  3.8──→ Node3 ──  5.9──→ Node5 ──  7.5──→ Node7 ──  9.7──→ Node14 ── 11.2──→ Node26 ── 15.2──→ Node29 ── 19.3──→ Node36 ── 21.5──→ Node40 
#> 
#> [7] ◎──  3.8──→ Node3 ──  5.9──→ Node5 ──  7.5──→ Node7 ──  9.7──→ Node14 ── 11.2──→ Node26 ── 15.2──→ Node29 ── 19.3──→ Node36 ── 23.2──→ Node71 
#> 
#> [8] ◎──  3.8──→ Node3 ──  5.9──→ Node5 ──  7.5──→ Node7 ──  9.7──→ Node14 ── 11.2──→ Node26 ── 15.2──→ Node29 ── 19.3──→ Node36 ── 23.2──→ Node71 ── 25.2──→ Node72 
#> 
#> [9] ◎──  3.8──→ Node3 ──  5.9──→ Node5 ──  7.5──→ Node7 ──  9.7──→ Node14 ── 11.2──→ Node26 ── 15.2──→ Node29 ── 19.3──→ Node36 ── 23.2──→ Node71 ── 25.2──→ Node72 ── 27.5──→ Node86 
#> 
#> [10] ◎──  3.8──→ Node3 ──  5.9──→ Node5 ──  7.5──→ Node7 ──  9.7──→ Node14 ── 11.2──→ Node26 ── 15.2──→ Node29 ── 19.3──→ Node36 ── 23.2──→ Node71 ── 25.2──→ Node72 ── 27.5──→ Node86