addColumns {simstudy} | R Documentation |
Add columns to existing data set
Description
Add columns to existing data set
Usage
addColumns(dtDefs, dtOld, envir = parent.frame())
Arguments
dtDefs |
Name of definitions for added columns |
dtOld |
Name of data table that is to be updated |
envir |
Environment the data definitions are evaluated in. Defaults to base::parent.frame. |
Value
an updated data.table that contains the added simulated data
Examples
# 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
dt <- addColumns(def2, dt)
dt
[Package simstudy version 0.8.1 Index]