add_col: Add a colum to a data frame

Description Usage Arguments Examples

Description

Similar to cbind, but allows you to specify the positoin. Will replac existing variable with the same name if present.

Usage

1
add_col(x, name, value, where = ncol(x) + 1)

Arguments

x

A data frame

name

Name of variabl to create. If variable of that name already exists

value

Values to insert.

where

position to insert. Use 1 to insert on LHS. RHS.

Examples

1
2
3
4
5
df <- data.frame(x = 1:5)
add_col(df, "y", runif(5))
add_col(df, "y", runif(5), where = 1)

add_col(df, "x", 5:1)

hadley/hadcol documentation built on May 31, 2019, 10:47 p.m.