enframe() returns a data.table::data.table() with two columns:
The names of x (or seq_along(x) if unnamed) and the values of x.
deframe() converts a two-column data.frame to a named vector.
If the data.frame only has a single column, an unnamed vector is returned.
Arguments
- x
(
vector()(enframe()) ordata.frame()(deframe()))
Vector to convert to adata.table::data.table().- name
(
character(1))
Name for the first column with names.- value
(
character(1))
Name for the second column with values.
Value
data.table::data.table() or named vector.
Examples
x = 1:3
enframe(x)
#> name value
#> <int> <int>
#> 1: 1 1
#> 2: 2 2
#> 3: 3 3
x = set_names(1:3, letters[1:3])
enframe(x, value = "x_values")
#> name x_values
#> <char> <int>
#> 1: a 1
#> 2: b 2
#> 3: c 3
