dtAggregate: Collapse data-tables

dtAggregateR Documentation

Collapse data-tables

Description

Collapse data-tables

Usage

dtAggregate(
  DT,
  aggr_on,
  measure.vars = c(),
  id.vars = c(),
  func = "sum",
  na.rm = TRUE
)

Arguments

DT

Data-table (required)

aggr_on

Character string (required): column-name that will be used to collapse on (i.e. combine all age-strata)

measure.vars

Character string (optional): column-names that will be collapsed (function will be applied to all these columns)

id.vars

Character string (optional): column-names that will remain stratified

N.b. if measure.vars is not provided, all columns that are not in id.vars and aggr_on will be assumed to be assumed

func

Character string (optional): function that will be applied to data (if optional, values will be summed)

na.rm

Logical (optional): if TRUE, removes NA from measure.vars columns before applying function (or passes na.rm=TRUE to function)

Value

Returns collapsed data.table


lshtm-vimc/prime documentation built on April 21, 2024, 3:21 a.m.