Learn R Programming

simstudy (version 0.7.0)

defDataAdd: Add single row to definitions table that will be used to add data to an existing data.table

Description

Add single row to definitions table that will be used to add data to an existing data.table

Usage

defDataAdd(
  dtDefs = NULL,
  varname,
  formula,
  variance = 0,
  dist = "normal",
  link = "identity"
)

Value

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

Arguments

dtDefs

Name of definition table to be modified. Null if this is a new definition.

varname

Name (string) of new variable

formula

An R expression for mean (string)

variance

Number

dist

Distribution. For possibilities, see details

link

The link function for the mean, see details

See Also

[distributions]

Examples

Run this code
# 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

Run the code above in your browser using DataLab