I'm looking to create a data frame that has all of the possible combinations from only one data frame (b).
Here is a reproducible example:
a <- data.frame(id = c(1, 2),
indicator = c('a', 'a'))
b <- data.frame(date = c('2020-01-01', '2020-02-01'))
Desired output:
data.frame(id = c(1, 1, 2, 2),
indicator = c('a', 'a', 'a', 'a'),
date = c('2020-01-01','2020-01-01', '2020-02-01', '2020-02-01'))
id indicator date
1 a 2020-01-01
1 a 2020-01-01
2 a 2020-02-01
2 a 2020-02-01
However, when I use the expand.grid function, I receive a nested data frame
expand.grid(a, b)