dh.meanByGroup: Describes a numeric variable by strata of another numeric...

View source: R/mean-by-group.R

dh.meanByGroupR Documentation

Describes a numeric variable by strata of another numeric grouping variable.

Description

This has similar functionality to tapply or the dplyr chain group_by %>% summarise. It offers additional flexilibity over ds.tapply in that it allows you to specify upper and lower values for each strata. By contrast, ds.tapply will produce a summary based on every unique value of the grouping variable, which may not always be what is required.

Usage

dh.meanByGroup(
  df = NULL,
  outcome = NULL,
  group_var = NULL,
  intervals = NULL,
  conns = NULL,
  checks = FALSE
)

Arguments

df

Character specifying a server-side data frame.

outcome

String specifying outcome variable within df.

group_var

String specifying grouping variable within 'df'.

intervals

Optionally, numeric vector defining how to stratify group_var. Values should specify alternately lower and upper values for each strata. If NULL, outcome is summarised by every unique value of group_var.

conns

DataSHIELD connections object.

checks

Logical; if TRUE checks are performed prior to running the function. Default is TRUE.

Value

Tibble containing mean values for each strata of group_var.

See Also

Other descriptive functions: dh.anyData(), dh.classDiscrepancy(), dh.createTableOne(), dh.getStats(), dh.lmTab()


lifecycle-project/ds-cs-functions documentation built on Nov. 18, 2024, 3:36 p.m.