defRepeatAdd: Add multiple (similar) rows to definitions table that will be...

View source: R/define_data.R

defRepeatAddR Documentation

Add multiple (similar) rows to definitions table that will be used to add data to an existing data.table

Description

Add multiple (similar) rows to definitions table that will be used to add data to an existing data.table

Usage

defRepeatAdd(
  dtDefs = NULL,
  nVars,
  prefix,
  formula,
  variance = 0,
  dist = "normal",
  link = "identity",
  id = "id"
)

Arguments

dtDefs

Definition data.table to be modified

nVars

Number of new variables to define

prefix

Prefix (character) for new variables

formula

An R expression for mean (string)

variance

Number or formula

dist

Distribution. For possibilities, see details

link

The link function for the mean, see details

id

A string indicating the field name for the unique record identifier

Details

The possible data distributions are: 'r paste0(.getDists(),collapse = ", ")'.

Value

A data.table named dtName that is an updated data definitions table

See Also

[distributions]

Examples

def <- defRepeatAdd(
  nVars = 4, prefix = "g", formula = "1/3;1/3;1/3",
  variance = 0, dist = "categorical"
)
def <- defDataAdd(def, varname = "a", formula = "1;1", dist = "trtAssign")
def <- defRepeatAdd(def, 8, "b", formula = "5 + a", variance = 3, dist = "normal")
def <- defDataAdd(def, "y", formula = "0.10", dist = "binary")

def

simstudy documentation built on Nov. 23, 2023, 1:06 a.m.