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

Description Usage Arguments Value Examples

View source: R/defDataAdd.R

Description

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

Usage

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

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

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 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

kgoldfeld/simstudy documentation built on Nov. 8, 2018, 7:41 p.m.