[R] expand.grid function

From: dxc13 <dxc13_at_health.state.ny.us>
Date: Sun, 23 Dec 2007 19:59:49 -0800 (PST)

useR's,

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 work. 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...

In a program I am writing, the user can specify any matrix. Does anyone 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 perform 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 variable.

If this isn't clear, I can try to be more detailed. Thank you for any thoughts.

Derek

-- 
View this message in context: http://www.nabble.com/expand.grid-function-tp14484403p14484403.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 24 Dec 2007 - 04:04:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 24 Dec 2007 - 05:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.