Add multiple (similar) rows to definitions table

defRepeat(
  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

The link function for the mean, see details

id

A string indicating the field name for the unique record identifier

Value

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

Details

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

See also

[distributions]

Examples

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

def
#>     varname     formula variance        dist     link
#>      <char>      <char>    <num>      <char>   <char>
#>  1:      g1 1/3;1/3;1/3        0 categorical identity
#>  2:      g2 1/3;1/3;1/3        0 categorical identity
#>  3:      g3 1/3;1/3;1/3        0 categorical identity
#>  4:      g4 1/3;1/3;1/3        0 categorical identity
#>  5:       a         1;1        0   trtAssign identity
#>  6:      b1       5 + a        3      normal identity
#>  7:      b2       5 + a        3      normal identity
#>  8:      b3       5 + a        3      normal identity
#>  9:      b4       5 + a        3      normal identity
#> 10:      b5       5 + a        3      normal identity
#> 11:      b6       5 + a        3      normal identity
#> 12:      b7       5 + a        3      normal identity
#> 13:      b8       5 + a        3      normal identity
#> 14:       y        0.10        0      binary identity