updateDefAdd {simstudy} | R Documentation |
Update definition table
Description
Updates row definition table created by functions defDataAdd and defReadAdd. (For tables created using defData or defRead use updateDef.)
Usage
updateDefAdd(
dtDefs,
changevar,
newformula = NULL,
newvariance = NULL,
newdist = NULL,
newlink = NULL,
remove = FALSE
)
Arguments
dtDefs |
Definition table that will be modified |
changevar |
Name of field definition that will be changed |
newformula |
New formula definition (defaults to NULL) |
newvariance |
New variance specification (defaults to NULL) |
newdist |
New distribution definition (defaults to NULL) |
newlink |
New link specification (defaults to NULL) |
remove |
If set to TRUE, remove definition (defaults to FALSE) |
Value
A string that represents the desired formula
Examples
# Define original data
defs <- defData(varname = "w", formula = 0, variance = 3, dist = "normal")
defs <- defData(defs, varname = "x", formula = "1 + w", variance = 1, dist = "normal")
defs <- defData(defs, varname = "z", formula = 4, variance = 1, dist = "normal")
# Define additional columns
defsA <- defDataAdd(varname = "a", formula = "w + x + z", variance = 2, dist = "normal")
set.seed(2001)
dt <- genData(10, defs)
dt <- addColumns(defsA, dt)
dt
# Modify definition of additional column
defsA <- updateDefAdd(dtDefs = defsA, changevar = "a", newformula = "w+z", newvariance = 1)
set.seed(2001)
dt <- genData(10, defs)
dt <- addColumns(defsA, dt)
dt
[Package simstudy version 0.8.1 Index]