metaAdd: Add meta data to an existing meta data object

View source: R/metaAdd.R

metaAddR Documentation

Add meta data to an existing meta data object

Description

The simplest is using only arguments data, meta.data, variable, and text (and unit if applicable). That will insert a line into the metadata describing the variable. The other two methods are for when a variable is a numeric code referring to factor levels (i.e. GRP or POP). If the character variable describing the levels is already present in data, use variable and var.char. If the levels are described in a data.frame, pass this data.frame as values.

Usage

metaAdd(
  data,
  meta.data,
  variable = NULL,
  text = NULL,
  header = NULL,
  var.char = NULL,
  var.unit = NULL,
  values = NULL,
  unit = NA,
  debug = F
)

Arguments

data

The dataset being described (i.e. a data.frame).

meta.data

The existing meta.data object (see metaInit).

variable

The name of the variable in the dataset to describe. Must supply either this or header.

text

Description of variable. If using header, text is not used.

header

Append lines to the header of the meta data. The lines will be added in the order they are given.

var.char

Match the numerical values of variable with character values in this column. Say, variable is ETHN, maybe var.char is ethnicity.

var.unit

Take unit from a column in data. The column must contain only one unique variable. NA values in the column are disregarded.

values

A data.frame with character values to merged with variable. values must contain a numeric column with the same name as variable. You cannot use both var.char and values.

unit

The unit of the variable. Will be printet in parenthesis when listing variables.

debug

Start by calling browser().

Value

Updated meta data object


philipdelff/pmxtricks documentation built on Nov. 11, 2024, 5:16 p.m.