[R] expand.grid function
dxc13 at health.state.ny.us
Mon Dec 24 05:41:16 CET 2007
Yes, that works perfectly. Thank you for your help!
Charilaos Skiadas-3 wrote:
> Hi Derek,
> On Dec 23, 2007, at 10:59 PM, dxc13 wrote:
>> I have used expand.grid() several times and like the results it
>> gives me. I
>> am now trying something with it that I have not been able to get to
>> For any n column matrix I would like to run this function on those
>> n columns
>> and store the results.
>> For example, if my matrix has 1 column then this is just expand.grid
>> (x =
>> column1). If my matrix has two columns, then I want expand.grid(x =
>> column1, y = column2), and so on for any number of columns...
> Does this do what you want (x is the matrix)?
> do.call(expand.grid, as.data.frame(x))
>> In a program I am writing, the user can specify any matrix. Does
>> know of a way for R to calculate this based on what the input
>> matrix is?
>> e.g. if this user gives a 3 column matrix, I want to be able to
>> expand.grid() on these 3 columns without having to hard code it b/c
>> I want
>> to have this small function embedded in my code and the results
>> stored as a
>> If this isn't clear, I can try to be more detailed. Thank you for any
> Haris Skiadas
> Department of Mathematics and Computer Science
> Hanover College
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
View this message in context: http://www.nabble.com/expand.grid-function-tp14484403p14484572.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help