On Jun 22, 2010, at 7:15 AM, sta...@quo.org wrote:
Hi Barbara,
You could use:
samples = matrix(rep(0,(5000*40)),ncol=40)
for(i in 1:5000) {
samples[i,] = sample(1:40,40)
}
Might also be a good time to use replicate():
samples = matrix(replicate(5000, sample(1:40) ), ncol=40, byrow=TRUE)
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 replaceme
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
;
> so that the the days are adjacent...
>
> -Lauri
>
> 2008/8/20, Moshe Olshansky <[EMAIL PROTECTED]>:
> > How about
> >
> > d[sample(length(d),10)]
> >
> >
> > --- On Wed, 20/8/08, Lauri Nikkinen <[EMAIL PROTECTED]> wrote:
> >
&
25"
so that the the days are adjacent...
-Lauri
2008/8/20, Moshe Olshansky <[EMAIL PROTECTED]>:
> How about
>
> d[sample(length(d),10)]
>
>
> --- On Wed, 20/8/08, Lauri Nikkinen <[EMAIL PROTECTED]> wrote:
>
> > From: Lauri Nikkinen <[EMAIL PROTECTED]&g
Lauri Nikkinen wrote:
Dear list,
I tried to find a solution for this problem from the archives but
couldn't find any. I would like sample sequence of ten days from
vector d
d <- seq(as.Date("2007-02-12"), as.Date("2008-08-18"), by="days")
so that the days follow each other (sample(d, 10) is no
How about
d[sample(length(d),10)]
--- On Wed, 20/8/08, Lauri Nikkinen <[EMAIL PROTECTED]> wrote:
> From: Lauri Nikkinen <[EMAIL PROTECTED]>
> Subject: [R] Random sequence of days?
> To: [EMAIL PROTECTED]
> Received: Wednesday, 20 August, 2008, 4:04 PM
> Dear l
Dear list,
I tried to find a solution for this problem from the archives but
couldn't find any. I would like sample sequence of ten days from
vector d
d <- seq(as.Date("2007-02-12"), as.Date("2008-08-18"), by="days")
so that the days follow each other (sample(d, 10) is not the
appropriate soluti
8 matches
Mail list logo