Hi Barbara, You could use:
samples = matrix(rep(0,(5000*40)),ncol=40) for(i in 1:5000) { samples[i,] = sample(1:40,40) } This will give you a matrix of samples, one per row. The second term in the "sample" function is the length of your sequence. By default "sample" samples without replacement, so there won't be any duplicates. The "for" loop is generally slower than using "lapply", but for just 5000 samples it won't make much difference. Cheers, Matt Asher StatisticsBlog.com > I have a sequence of number from 1 to 40 and I have to extract a random > sequence, for example: > 1) 1, 2 3, 4, ...40 > 2) 2, 10, 9 , 25.... > > e so on for 5000 times. How I can do???? > Thanks > [[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. > ______________________________________________ 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.