Learn R Programming

metasnf (version 2.1.2)

add_columns: Add columns to a data frame

Description

Add new columns to a data frame by specifying their names and a value to initialize them with.

Usage

add_columns(df, cols, value = NA)

Value

A data frame containing with the same columns as the df argument as well as the new columns specified in the cols argument.

Arguments

df

The data frame to extend.

cols

The vector containing new column names.

value

The values stored in the newly added columns. NA by default.