Values accumulate from the bottom of the ontology to the top at each node, and are computed only from the values of the direct children of each node.

compute_hierarchical(df, fun, compute_column, result_column,
  include_node = FALSE, na.rm = NULL, taxon_column = "taxons")

Arguments

df

A flat ontology data.frame with a taxons column

fun

The function to run as a character object, e.g. "mean".

compute_column

The column of values to use for the function computation.

result_column

The name of the output column.

include_node

Logical, should values assigned to non-leaf nodes be included in calculation?

na.rm

If TRUE or FALSE, passed as a parameter to fun. If NULL (default), is ignored.

taxon_column

The name of the taxons column. Default is "taxons"

Value

A flat ontology data.frame with the result_column added. The taxon column will be moved to the last column position. This should behave similarly to mutate().

Examples

flat_ontology2 <- flat_ontology %>% compute_hierarchical("mean","n_children","mean_children", include_node = TRUE)
#> Error in flat_ontology %>% compute_hierarchical("mean", "n_children", "mean_children", include_node = TRUE): could not find function "%>%"