import_vardef: Import definition of variables

Description Usage Arguments Details Value Methods (by class) See Also Examples

Description

Import definition of several variables and create a DatabaseDef object.

Usage

1
2
3
4
import_vardef(vardf, col_replacement)

## S4 method for signature 'data.frame'
import_vardef(vardf, col_replacement)

Arguments

vardf

A data.frame that represents a definition of variables table.

col_replacement

Replacement for the columns

Details

The col_replacement parameter by default are : c(rname = "rname", varlabel = "varlabel", description = "description", type = "type", commentary = "commentary", flevel = "flevel", flabel = "flabel"). It is possible to overwrite by passing c(key = "value") in the colnames parameter.

Value

Return a DatabaseDef object.

Methods (by class)

See Also

To create a definition of variables table from a database, use /link{descvars_skeleton}.

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
# create a simple definition of variables table in a data.frame
testdf <- read.table(header = TRUE, stringsAsFactors=FALSE,
  text="
  rname  varlabel  description  type  flevel1  name1  flevel2  name2  flevel3  name3
  id        Identification  'Unique ID'  integer NA NA NA NA NA NA
  age       'Age of patient' NA integer NA NA NA NA NA NA
  city      'City'  'City where live actually' factor 1 Strasbourg 2 Paris 3 London
  weight    'Weight' 'Weight at the beginning of the study' numeric NA NA NA NA NA NA
  ")
# create the DatabaseDef object
import_vardef(testdf)

# When the headers are not standard, it's possible to pass a
# replacement dictionnary
names(testdf) <- c("variable", "etiquette", "description",
                   "type",  "code1",  "modalite1",  "code2",  "modalite2",
                   "code3",  "modalite3")
head(testdf)
import_vardef(testdf,
              col_replacement =  c("rname" = "variable",
                                   "varlabel"    = "etiquette",
                                   "flevel"    = "code",
                                   "flabel"     = "modalite")
)

jomuller/vartors documentation built on May 19, 2019, 7:26 p.m.