Question: These are my haves:

```
vec <- seq(1, 3, by = 1)
df <- data.frame(x1 = c("a1", "a2"))

```

and this is my wants:

```
  x1 x2
1 a1  1
2 a2  1
3 a1  2
4 a2  2
5 a1  3
6 a2  3

```

I basically want to replicate the data frame according to the values in the vector vec. This is my working (possibly inefficient approach):

```
vec <- seq(1, 3, by = 1)
df <- data.frame(x1 = c("a1", "a2"))
results <- NULL

for (v in vec) {
    results <- rbind(results, cbind(df, x2=v))
}

results

```

Maybe there is a better way? Sorry this is more like a code review. Thanks!

PS:

Thanks for all your great answers. Sorry should have thought about some myself but it is early here. I will have to accept one. Sorry no hard feelings!

Answer: 
You can use `crossing` :

```
tidyr::crossing(df, vec) %>% dplyr::arrange(vec)

#   x1      vec
#  <chr> <dbl>
#1 a1        1
#2 a2        1
#3 a1        2
#4 a2        2
#5 a1        3
#6 a2        3

```

Also,

```
tidyr::expand_grid(df, vec) %>% dplyr::arrange(vec)

```
`expand.grid` can give all combinations of two vectors.

```
expand.grid(x1 = df$x1, vec = vec)
#>     x1  vec
#> 1   a1    1
#> 2   a2    1
#> 3   a1    2
#> 4   a2    2
#> 5   a1    3
#> 6   a2    3

```