tidy_vector: Tidy a Named Atomic Vector: Bind Its Values with Its Names

Description Usage Arguments Value Examples

View source: R/tidy_vector.R

Description

cbind a named atomic vector's values with its names to form id (from the names) and content columns.

Usage

1
tidy_vector(x, id.name = "id", content.name = "content", ...)

Arguments

x

A named atomic vector.

id.name

The name to use for the column created from the vector names.

content.name

The name to use for the column created from the vector values.

...

ignored.

Value

Returns a data.table with the names from the vector as an id column.

Examples

1
2
x <- setNames(sample(LETTERS[1:6], 1000, TRUE), sample(state.name[1:5], 1000, TRUE))
tidy_vector(x)

Example output

              id content
   1:    Alabama       A
   2: California       D
   3:   Arkansas       E
   4: California       F
   5:    Alabama       A
  ---                   
 996:    Alabama       A
 997: California       B
 998:    Arizona       D
 999:     Alaska       A
1000:   Arkansas       C

textshape documentation built on May 29, 2021, 1:07 a.m.