R/define_data.R
defDataAdd.Rd
Add single row to definitions table that will be used to add data to an existing data.table
defDataAdd(
dtDefs = NULL,
varname,
formula,
variance = 0,
dist = "normal",
link = "identity"
)
A data.table named dtName that is an updated data definitions table
[distributions]
# New data set
def <- defData(varname = "xNr", dist = "nonrandom", formula = 7, id = "idnum")
def <- defData(def, varname = "xUni", dist = "uniform", formula = "10;20")
dt <- genData(10, def)
# Add columns to dt
def2 <- defDataAdd(varname = "y1", formula = 10, variance = 3)
def2 <- defDataAdd(def2, varname = "y2", formula = .5, dist = "binary")
def2
#> varname formula variance dist link
#> <char> <num> <num> <char> <char>
#> 1: y1 10.0 3 normal identity
#> 2: y2 0.5 0 binary identity
dt <- addColumns(def2, dt)
dt
#> Key: <idnum>
#> idnum xNr xUni y1 y2
#> <int> <num> <num> <num> <int>
#> 1: 1 7 18.10197 8.704022 1
#> 2: 2 7 10.06193 12.713904 0
#> 3: 3 7 13.95427 8.827621 0
#> 4: 4 7 18.59115 7.158750 1
#> 5: 5 7 13.56085 9.057990 0
#> 6: 6 7 15.61046 11.386552 0
#> 7: 7 7 15.18909 8.796868 0
#> 8: 8 7 17.38799 7.889894 1
#> 9: 9 7 11.79224 9.181361 1
#> 10: 10 7 10.26153 12.108837 0