Skip to contents

Internal function to add a new column to a data frame and optionally position it before or after a specified column.

Usage

append_column(.data, new_col, .before = NULL, .after = NULL)

Arguments

.data

A data frame to which the column will be added.

new_col

A vector containing the values of the new column to append. The name of this vector will be used as the column name in the data frame.

.before

(Optional) A string specifying the name of the column before which the new column should be inserted. Defaults to `NULL`.

.after

(Optional) A string specifying the name of the column after which the new column should be inserted. Defaults to `NULL`.

Value

A data frame with the new column added at the specified position or at the end if no position is specified.

Details

If both `.before` and `.after` are provided, `.before` takes precedence. If neither is provided, the new column is appended at the end of the data frame.

The column name is derived from the name of the input vector `new_col`.