enframe()
converts named atomic vectors or lists to one- or two-column
data frames.
For a list, the result will be a nested tibble with a column of type list
.
For unnamed vectors, the natural sequence is used as name column.
deframe()
converts two-column data frames to a named vector or list,
using the first column as name and the second column as value.
If the input has only one column, an unnamed vector is returned.
enframe(x, name = "name", value = "value") deframe(x)
x | An atomic vector (for |
---|---|
name, value | Names of the columns that store the names and values.
If |
A tibble with two columns (if name
is not NULL
, the default)
or one column (otherwise).
enframe(1:3)#> # A tibble: 3 x 2 #> name value #> <int> <int> #> 1 1 1 #> 2 2 2 #> 3 3 3#> # A tibble: 2 x 2 #> name value #> <chr> <dbl> #> 1 a 5 #> 2 b 7#> # A tibble: 3 x 2 #> name value #> <chr> <list> #> 1 one <dbl [1]> #> 2 two <int [2]> #> 3 three <int [3]>deframe(enframe(1:3))#> 1 2 3 #> 1 2 3#> [1] 1 2 3#> [[1]] #> [1] 1 #> #> [[2]] #> [1] 2 #> #> [[3]] #> [1] 3 #>