standardize_column: Confirm that a column is in the data, and rename data to...

View source: R/format_vpc_input_data.R

standardize_columnR Documentation

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)

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.

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.


ronkeizer/vpc documentation built on May 11, 2023, 11:09 p.m.