Hi Rachel, You might also try
apply(expand.grid(rep(list(1:6), 4)), 1, paste, collapse = "", sep = "") HTH, Jorge * * On Tue, Mar 22, 2011 at 6:41 PM, Rachel Chu <> wrote: > Hi there, > > I am currently working on a R programming project and got stuck. > I am supposed to generate a set of possibilities of 1296 different > combinations of 4 numbers, ie. 1111, 1234, 2361, (only contain 1 to 6) in a > matrix form > here is what I got which has not been working as it keeps coming out with > the same number on the row.. > > The code: > gl1<- gl(1296,1,length=1296, labels=1:1296, ordered=true) > s<-matrix(gl1, nrow=1296,ncol=4) > > and i want to get a result which will provide me 1296 outcomes of DIFFERENT > COMBINATIONS of numbers (from 1 to 6) > e.g. > [1] 1111 > ... > [1295] 6665 > [1296] 6666 > > if anyone could email me back with what I am doing wrong and what I should > actually do i would be extremely thankful! > (I am doing my project and am so stressed because of getting stuck on the > supposedly easier problem..) > > Thanks again! > > xoxo > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.