Learn R Programming

f1dataR (version 2.0.1)

add_col_if_absent: Add Column if Absent

Description

Adds a column (with the name specified in column_name) of NA values to a data.frame or tibble. If that column already exists, no change will be made to data. NA value type (character, integer, real, logical) may be specified.

Usage

add_col_if_absent(data, column_name, na_type = NA)

Value

the data.frame as provided (converted to tibble)

Arguments

data

a data.frame or tibble to which a column may be added

column_name

the name of the column to be added if it doesn't exist

na_type

the type of NA value to use for the column values. Default to basic NA