I have two lists with different structure:
listA <- list(c(\"a\",\"b\",\"c\"), c(\"d\",\"e\"))
listB <- list(0.05, 0.5)
listA
[[1]]
[1] \"a\" \"b\" \"c\"
If looking for a tidyverse
solution, here is the analogue to the accepted answer. Using the dfr
suffix to the map
function family enables a very simple solution which should also be faster than do.call("rbind")
.
library(tidyverse)
listA <- list(c("a","b","c"), c("d","e"))
listB <- list(0.05, 0.5)
map2_dfr(listA, listB, ~ tibble(A = .x, B = .y))
#> # A tibble: 5 x 2
#> A B
#>
#> 1 a 0.05
#> 2 b 0.05
#> 3 c 0.05
#> 4 d 0.5
#> 5 e 0.5
Created on 2019-02-12 by the reprex package (v0.2.1)