defReadAdd: Read external csv data set definitions for adding columns

Description Usage Arguments Value Examples

View source: R/defReadAdd.R

Description

Read external csv data set definitions for adding columns

Usage

1
defReadAdd(filen)

Arguments

filen

String file name, including full path. Must be a csv file.

Value

A data.table with data set definitions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Create temporary external "csv" files

test1 <- c("varname,formula,variance,dist,link",
           "nr,7, 0,nonrandom,identity"
          )

tfcsv1 <- tempfile()
writeLines(test1, tfcsv1)

test2 <- c("varname,formula,variance,dist,link",
           "x1,.4, 0,binary,identity",
           "y1,nr + x1 * 2,8,normal,identity",
           "y2,nr - 0.2 * x1,0,poisson, log"
          )

tfcsv2 <- tempfile()
writeLines(test2, tfcsv2)

# Generate data based on external definitions

defs <- defRead(tfcsv1)
dt <- genData(5, defs)
dt

# Add additional data based on external definitions

defs2 <- defReadAdd(tfcsv2)
dt <- addColumns(defs2, dt)
dt

unlink(tfcsv1)
unlink(tfcsv2)

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