The background: I have a function which takes some parameters. I want to have the result of the function for all possible parameter combinations.
A simplified example:
I think you just want expand.grid
:
> colors = c("red", "green", "blue")
> days = c("Monday", "Tuesday")
> expand.grid(colors,days)
Var1 Var2
1 red Monday
2 green Monday
3 blue Monday
4 red Tuesday
5 green Tuesday
6 blue Tuesday
And, if you want to specify the column names in the same line:
> expand.grid(color = colors, day = days)
color day
1 red Monday
2 green Monday
3 blue Monday
4 red Tuesday
5 green Tuesday
6 blue Tuesday