R/define_data.R
defRepeatAdd.Rd
Add multiple (similar) rows to definitions table that will be used to add data to an existing data.table
defRepeatAdd(
dtDefs = NULL,
nVars,
prefix,
formula,
variance = 0,
dist = "normal",
link = "identity",
id = "id"
)
Definition data.table to be modified
Number of new variables to define
Prefix (character) for new variables
An R expression for mean (string)
Number or formula
Distribution. For possibilities, see details
The link function for the mean, see details
A string indicating the field name for the unique record identifier
A data.table named dtName that is an updated data definitions table
The possible data distributions are: `r paste0(.getDists(),collapse = ", ")`.
[distributions]
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
#> 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