computeFunctionByFactors: Compute results using an arbitrary function on columns in a...

View source: R/computeFunctionByFactors.R

computeFunctionByFactorsR Documentation

Compute results using an arbitrary function on columns in a dataframe, by a set of factor levels

Description

Function to compute results from an arbitrary function (fcn) on colunms in a dataframe, by a set of factor levels

Usage

computeFunctionByFactors(
  df,
  fcn = "sum",
  factors = NULL,
  vars = NULL,
  sortBy = NULL,
  ascending = TRUE,
  debug = FALSE
)

Arguments

df
  • dataframe (or object that can be cast to a dataframe) with variables and factors

fcn
  • function name AS CHARACTER STRING to apply to each var in vars by each unique factor level combination

factors
  • vector of names of columns in df to serve as factors in the function applications

vars
  • vector of names of column in df that the function should be applied to

sortBy
  • vector of factor column names to sort results by

ascending
  • flag (T/F) to sort in ascending/descending order

debug
  • flag (T/F) to print debugging info

Value

  dataframe of results with columns corresponding to factors and vars

wStockhausen/wtsUtilities documentation built on March 16, 2024, 10:38 a.m.