Hi Mayooran It is better to keep your mails on rhelp. Others could answer too.
see in line > -----Original Message----- > From: m.thevar...@massey.ac.nz <m.thevar...@massey.ac.nz> > Sent: Wednesday, June 5, 2019 11:55 AM > To: PIKAL Petr <petr.pi...@precheza.cz> > Subject: Re: How to generate mutiple set of samples in R? > > Hello Petr > Here given below that manual code (generate first three set of samples > each contains 200 observations), but I need to write common function for > generate set of samples, > > N <- 1e7 > n <- 200 #sample size > m <- 3 # number of samples > indx <- 1:N > start1 <- sort(sample(indx,1)) this will select **one** random number from indx so easier version is start1 <- sample(indx,1)) > start2 <- sort(sample(start1+1,1)) > start3 <- sort(sample(start2+1,1)) these will select one random number from 1:start1 or 1:start2, again easier version is start2 <- sample(start1+1,1) > > grab.samp1 <- start1:(start1+n-1) > grab.samp2 <- start2:(start2+n-1) > grab.samp3 <- start3:(start3+n-1) and this will just make vector of of 200 consecutive numbers. So startn <- sample(indx,200) gives you 200 random numbers from 1:N vector. And this will give you list of m vectors with 200 consecutive numbers starting randomly. lll <- vector("list", m) for (i in 1:m) { lll[[i]] <- startn[i]:(startn[i]+n-1) } Is this what you wanted? Cheers Petr > > grab.samp1 > grab.samp2 > grab.samp3 > > > If you have any ideas please let me know. > > > cheers > > > Mayooran > > > _____________________________________ > Sent from http://r.789695.n4.nabble.com Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about processing and protection of business partner’s personal data are available on website: https://www.precheza.cz/en/personal-data-protection-principles/ Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/ ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.