v_to_df: Vector to data frame

View source: R/transform.R

v_to_dfR Documentation

Vector to data frame

Description

Transform a vector to a data.frame. If it has names, these will be added as rownames unless name_col is specified to a chr.

Usage

v_to_df(x, value_col = "value", name_col = F)

Arguments

x

(vector) A vector.

value_col

(chr) Name of the column with values. If NA, will use the name of x.

name_col

(chr/lgl) Name of the column with names. If given, will not use rownames and use an explicit column.

Value

a data.frame

Examples

v_to_df(1:4)
v_to_df(c(a = 1, b = 2, c = 3, d = 4))
v_to_df(c(a = 1, b = 2, c = 3, d = 4), name_col = "name")

Deleetdk/kirkegaard documentation built on April 22, 2024, 5:22 p.m.