It is trivial to bind vectors into a data.frame with data.frame(), tibble(), or bind_cols():
library(tidyverse)
x <- 1:5
y <- letters[1:5]
d <- tibble(x, y)
What is the most efficient way to reverse this operation - i.e., take a dataframe and break it into a list with length equal to the ncol(d)? In the example above, the desired output would look like this:
> list(x = x, y = y)
$x
[1] 1 2 3 4 5
$y
[1] "a" "b" "c" "d" "e"
A single function that accomplishes this would be useful, for example, when piping a dataframe to pmap():
d %>%
break_into_list() %>% # missing function here
pmap(function(x, y) paste(x, y)) # scales to dataframe with ncol > 2