calcColumnDiffs: Calculate differences between dataframe columns by row

View source: R/calcColumnDiffs.R

calcColumnDiffsR Documentation

Calculate differences between dataframe columns by row

Description

Function to calculate differences between dataframe columns by row.

Usage

calcColumnDiffs(
  dfr,
  col,
  cols = NULL,
  adjacent = FALSE,
  dropCols = TRUE,
  dropBase = FALSE
)

Arguments

dfr
  • dataframe

col
  • column name for base

cols
  • vector of column names to compute by-row differences for (or NULL)

adjacent
  • flag to compute differences between "adjacent" columns (default=FALSE)

dropCols
  • flag to drop original columns involved in differences (default=TRUE)

dropBase
  • flag to drop base column involved in differences (default=FALSE)

Details

If cols is NULL, then differences will be computed as if cols was the vector of names of columns to the "right" of col. If adjacent=FALSE, then all differences are relative to col as the base. Otherwise, after the first difference, the base column is sequentially moved through those in cols.

Value

copy of input dataframe, with columns inv with extra columns representing column differences


wStockhausen/wtsUtilities documentation built on Feb. 3, 2025, 6:29 a.m.