add_vector_to_df: Add vector to a (n x 2) data frame

View source: R/operations.R

add_vector_to_dfR Documentation

Add vector to a (n x 2) data frame

Description

Given a vector, adds each value and its corresponding name to a data frame of 2 columns as new rows, where the name fills in the 1st column and the value the 2nd column.

Usage

add_vector_to_df(df, vec)

Arguments

df

data.frame, with n rows and 2 columns

vec

a vector

Value

a data.frame with additional rows and each element as a character.

Examples

df = data.frame(c(0,0,1), c(0,0,2))
vec = 1:3
names(vec) = c("a","b","c")

add_vector_to_df(df, vec)


usefun documentation built on Sept. 17, 2023, 9:06 a.m.