Hi Mayooran
It is better to keep your mails on rhelp. Others could answer too.
see in line
> -----Original Message-----
> From: m.thevaraja at massey.ac.nz <m.thevaraja at massey.ac.nz>
> Sent: Wednesday, June 5, 2019 11:55 AM
> To: PIKAL Petr <petr.pikal at 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/