I would like to join a 2 dimensional tibble to another one as follows:
library(tidyverse)
set.seed(1)
tib1 <- tibble(locid = seq(2))
tib2 <- tibble(x=runif(1), y = x * 2)
I've tried the following:
tib3 <- tib1 %>%
mutate(z = list(tib2)) %>%
unnest
However, this produces:
locid x y
1 0.2655087 0.5310173
2 0.2655087 0.5310173
i.e. the values are repeated. I'd like to make it such that tib2 gets resampled for each row. How is this possible?
The expected output would be:
locid x y
1 0.2655087 0.5310173
2 0.1848823 0.3697645
Thank you very much.