Dear Brandon, On Tue, Dec 2, 2008 at 10:46 PM, Dylan Beaudette <[EMAIL PROTECTED]> wrote: > On Tue, Dec 2, 2008 at 7:42 PM, philozine <[EMAIL PROTECTED]> wrote: >> Dear all: >> >> This is one of those "should be easy" problems that I'm having great >> difficulty solving. I have a vector containing ID codes, and I need to >> generate a 3-column matrix that contains all possible combinations of three. >> >> For example, my ID vector looks like this: >> A >> B >> C >> D >> E >> >> I need to generate a matrix that looks like this: >> A B C >> A B D >> A B E >> A C B >> A C D >> A C E >> A D B >> A D C >> A D E > > Hi, > > Does this do what you want? > > expand.grid(letters[1:5], letters[1:5], letters[1:5]) > > > D >
Have a look at urnsamples() in the prob package. ID <- LETTERS[1:5] urnsamples(ID, size = 3, replace = FALSE, ordered = FALSE) Best, Jay *************************************************** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics & Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ ______________________________________________ R-help@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.