rgp (version 0.4-1)

exprDepth: Complexity measures for R functions and expressions

Description

exprDepth returns the depth of the tree representation ("exression tree") of an R expression. funcDepth returns the tree depth of the body expression of an R function. exprSize returns the number of nodes in the tree of an R expression. exprLeaves returns the number of leave nodes in the tree of an R expression. exprCount returns the number of tree nodes in an R expression matching a given predicate. funcSize returns the number of nodes in the body expression tree of an R function. funcLeaves returns the number of leave nodes in the body expression tree of an R function. funcCount returns the number of nodes in an R function body expression matching a given predicate. exprVisitationLength returns the visitation length of the tree of an R expression. The visitation length is the total number of nodes in all possible subtrees of a tree. funcVisitationLength returns the visitation length of the body expression tree of an R function. fastExprVisitationLength and fastFuncVisitationLength are variants written in optimized C code. The visitation length can be interpreted as the size of the expression obtained by substituting all inner functions by their function bodies (see "Crossover Bias in Genetic Programming", Maarten Keijzer and James Foster).

Usage

exprDepth(expr)
funcDepth(func)
exprSize(expr)
exprLeaves(expr)
exprCount(expr, predicate = function(node) TRUE)
funcSize(func)
funcLeaves(func)
funcCount(func, predicate = function(node) TRUE)
exprVisitationLength(expr, intermediateResults = FALSE)
fastExprVisitationLength(expr, intermediateResults = FALSE)
funcVisitationLength(func, intermediateResults = FALSE)
fastFuncVisitationLength(func, intermediateResults = FALSE)

Arguments

expr
An R expression.
func
An R function.
predicate
An R predicate (function with range type logical).
intermediateResults
Whether to return complexity measures for all subtrees also.