set_variable_labels: Set variable attributes

Description Usage Arguments Details Value Note Examples

View source: R/set_funs.R

Description

These functions allow you to embed attributes in data so that you only need to think about them once. Some functions may overwrite or delete attributes in data, so it is recommended that you create a meta data object with the build_meta function after you have set variable labels, groups, notes, abbreviations, and units.

Usage

1
2
3
4
5
6
7
8
9

Arguments

data

a data frame.

...

name-value pairs of variable groups and names (see examples)

Details

For set_variable_labels, names are variables and values are labels. For example, writing gfr_variable = "estimated GFR" as an input to set_variable_labels will set the label for gfr_variable as the indicated string. Since GFR is an acronym, we would also want to use set_variable_abbrs() and say gfr_variable = c("GFR" = "glomerular filtration rate") (see examples).

Value

a tibble, adorned with additional attributes based on user input.

Note

The set_variable_labels function in tibbleOne is a wrapper of the labelled function, developed by Joseph Larmarange.

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
df <- data.frame(
  gfr = c(1,2,3),
  sbp = c(3,2,1)
)

df <- set_variable_labels(df,
  gfr = 'Estimated GFR',
  sbp = 'Systolic BP'
)

df <- set_variable_units(df,
  gfr = 'mL/min/1.73 m2',
  sbp = 'mm Hg'
)

df <- set_variable_abbrs(df,
  gfr = c("GFR" = "glomerular filtration rate", "min" = 'minute'),
  sbp = c("BP" = "blood pressure")
)

df <- set_variable_notes(df,
  sbp = "blood pressure was measured by trained personnel"
)

build_meta(df)

tibbleOne documentation built on Jan. 29, 2020, 5:07 p.m.