Learn R Programming

simstudy (version 0.7.0)

defRepeatAdd: 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"
)

Value

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

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 = ", ")`.

See Also

[distributions]

Examples

Run this code
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

Run the code above in your browser using DataLab