0

I have following three variables

id = c(1,2) 
year = c(90,91)
group = c('a','b')

What is the most efficient way to create the following dataframe structure ?

id year group
1   90    a
1   91    a
1   90    b
1   91    b
2   90    a
2   91    a
...
Jb_Eyd
  • 635
  • 1
  • 7
  • 20
  • 1
    `expand.grid(id, year, group)` or `library(tidyverse);crossing(id, year, group)` – akrun Feb 14 '19 at 17:24
  • Possible duplicate of [Unique combination of all elements from two (or more) vectors](https://stackoverflow.com/questions/11388359/unique-combination-of-all-elements-from-two-or-more-vectors) – divibisan Feb 14 '19 at 17:53

0 Answers0