colors <- c("red", "green", "yellow")
vehicles <- c("bicycle", "car", "submarine", "airplane")
crossing(colors,vehicles)
## # A tibble: 12 x 2
## colors vehicles
## <chr> <chr>
## 1 green airplane
## 2 green bicycle
## 3 green car
## 4 green submarine
## 5 red airplane
## 6 red bicycle
## 7 red car
## 8 red submarine
## 9 yellow airplane
## 10 yellow bicycle
## 11 yellow car
## 12 yellow submarine
colored_vehicles <- purrr::cross2(colors, vehicles) %>%
purrr::map_chr(~paste(.[[1]], .[[2]]))
colored_vehicles
## [1] "red bicycle" "green bicycle" "yellow bicycle" "red car"
## [5] "green car" "yellow car" "red submarine" "green submarine"
## [9] "yellow submarine" "red airplane" "green airplane" "yellow airplane"
a <- 11:15
b <- 1:3
output <- purrr::cross2(a, b) %>%
purrr::map_dbl(~( .[[1]] * .[[2]] ))
output
## [1] 11 12 13 14 15 22 24 26 28 30 33 36 39 42 45