Learn R Programming

dendrometry (version 0.0.4)

baseFunction: Recursive function for creating nested data structures

Description

Internal recursive function that creates nested list structures by sequentially grouping data by factors and applying a function to each subset. This is the core engine behind nestedFunBuilder and related functions.

Usage

baseFunction(currentData, remainingFactors, fun = identity, funArgs = list())

Value

A nested list structure where each level corresponds to a factor, or the result of applying fun to the data subset if no factors remain.

Arguments

currentData

data frame containing the current subset of data to process.

remainingFactors

character vector of factor names still to be processed.

fun

function to apply to each final data subset. Default is identity.

funArgs

list of additional arguments to pass to fun.

Details

This function works recursively:

  • Base case: If no factors remain, applies fun to the current data

  • Recursive case: Groups data by the first remaining factor, then calls itself on each subset with the remaining factors