Home > Net >  How to generate arguments of a function
How to generate arguments of a function

Time:10-20

I have a matrixp, each column is an argument of function expand.grid, how do I have something like expand.grid(p[,1],p[,2],...)?

CodePudding user response:

We may convert the matrix to a list of vectors and apply expand.grid

expand.grid(asplit(p, 2))

CodePudding user response:

You could also do:

expand.grid(data.frame(p))
  •  Tags:  
  • r
  • Related