Skip to contents

Get the value from a column in a data frame if the value is a column there, otherwise, the value should be a scalar or the length of the data.

Usage

getColumnValueOrNot(data, value, prefix = "X")

Arguments

data

A data.frame or similar object

value

A character string giving the name of a column in the data, a scalar, or a vector the same length as the data

prefix

The prefix to use if a column must be added (it will be used as the full column name if it is not already in the dataset or it will be prepended to the maximum column name if not.)

Value

A list with elements named "data", "name" giving the data with a column named "name" with the value in that column.