Consider this simple example
myfunc <- function(x){
paste(x,c('a','b','c'))
}
tibble(var = c(1,2,3)) %>%
mutate(multi_output = map(var, ~myfunc(.x)))
# A tibble: 3 x 2
var multi_output
<dbl> <list>
1 1 <chr [3]>
2 2 <chr [3]>
3 3 <chr [3]>
The problem is that I would like the multi_output
to correspond to three different new columns, something like
# A tibble: 3 x 4
var v1 v2 v3
<dbl> <chr> <chr> <chr>
1 1 1 a 1 b 1 c
2 2 2 a 2 b 2 c
3 3 3 a 3 b 3 c
How can I achieve that?
Thanks!