Expand.grid is simple to use, but it requires entering the specific vectors:
a = 1:5
b = 2:5
c = 3:5
df = expand.grid(a,b,c)
But a b and c are arbitrary and are not real names, how can I use it for unknown variables or a list. I tried:
rm(list = ls())
a = 1:5
b = 2:5
c = 3:5
l = ls()
[1] "a" "b" "c"
get(l[1])
[1] 1 2 3 4 5
df = expand.grid(get(l))
L is the list of variables and get gives pulls the variables by name so I expected the two to give the same result but it gives the result of only a.
How can I get the desired result for expand.grid without entering static values?