Hi Rachel, First off, getting very stressed when you get stuck is probably not the most helpful approach. Seeking support from someone who knows what to do is an excellent idea, but in the case of classes or homework, it is best to go to your teacher, instructor, or professor. That is what he or she is there for, and most teachers are happy to help students who show up to office hours and are ready and willing to learn. Which is a rather long way of saying, the R-help list is not for homework questions (but your teacher is!!!!).
That said, gl() strikes me as a less than ideal way of generating combinations. So one hint would be to check out ?combn Also, look at the examples. Compare the output from: example(gl) example(combn) Which one seems closer to what you are after? Take a deep breath (or two), and work calmly and persistently at the problem and I'm sure you'll get there! Good luck, Josh On Tue, Mar 22, 2011 at 3:41 PM, Rachel Chu <aki.rac...@gmail.com> 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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ ______________________________________________ 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.