Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

enframe

Convert a Named Vector into a data.table and Vice Versa


Description

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.

Usage

enframe(x, name = "name", value = "value")

deframe(x)

Arguments

x

(vector() (enframe()) or data.frame() (deframe()))
Vector to convert to a data.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)

x = set_names(1:3, letters[1:3])
enframe(x, value = "x_values")

mlr3misc

Helper Functions for 'mlr3'

v0.10.0
LGPL-3
Authors
Michel Lang [cre, aut] (<https://orcid.org/0000-0001-9754-0393>), Patrick Schratz [aut] (<https://orcid.org/0000-0003-0748-6624>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.