compute_hierarchical: Compute values hierarchicaly over a flat ontology

Description Usage Arguments Value Examples

View source: R/ontology.R

Description

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.

Usage

1
2
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

1
2
3
flat_ontology2 <- flat_ontology %>%
  compute_hierarchical("mean","n_children","mean_children",
                       include_node = TRUE)

AllenInstitute/cocoframer documentation built on May 21, 2020, 3:09 a.m.