Learn R Programming

vpc (version 1.2.4)

standardize_column: Confirm that a column is in the data, and rename data to prepare that column for later use.

Description

Confirm that a column is in the data, and rename data to prepare that column for later use.

Usage

standardize_column(dat, cols, colname, coldesc, what, default)

Value

If colname is already named colname in dat,

dat unchanged. If not, check if dat has that column name already, and if so, name the existing dat[[colname]] to

dat[[paste0(colname, ".old")]] and then rename

cols[[colname]] to colname.

Arguments

dat

An input data.frame or similar object

cols

A list with an element for colname giving the name for colname in dat.

colname

The name of the column (character scalar)

coldesc

The description of the column (character scalar)

what

The description of the data (typically "observed" or "simulated")

default

A default value (scalar or vector) to use if the column is not found.