change_composition: Change composition

View source: R/change_composition.R

change_compositionR Documentation

Change composition

Description

This makes a change to a composition in the specified way and automatically reallocates to/from other parts of the composition proportionally. It primarily exists as a utility function to make reporting easier.

Usage

change_composition(
  composition,
  main_part,
  at_expense_of = NULL,
  main_change,
  comp_labels
)

Arguments

composition

This should be the starting composition as a data frame.

main_part

part the main change is happening to.

at_expense_of

Parts the main change is at the expense of/ reallocated to.

main_change

Magnitude and direction of change e.g. +1, -0.5.

comp_labels

Compositional column labels.

Value

Composition after reallocating as described.

Examples

new_comp <-
change_composition(
 composition = simdata[1,],
 main_part = "moderate",
 main_change = +0.5,
 comp_labels = c("vigorous", "moderate", "light", "sedentary", "sleep")
 )

OxWearables/epicoda documentation built on Dec. 7, 2022, 9:07 p.m.