To pick random elements to sample, you can just use the sample function

sample(1:5,3,replace=T/F) # pick true or false as needed for your data.

If you replicate this, you should have no problem.

replicate(100,function() return(sample(1:5,3,replace=T/F)))

This will be plenty fast, but if you get into very large scale boot
strapping, you might want to vectorize the whole thing. That's easily done
with replace = T (just take 3*100 samples and then convert the output vector
to a matrix) but I'm not sure its quite as easy with replace = F.

Hope this helps,

Michael

On Wed, Aug 10, 2011 at 2:37 PM, Vikram Chhatre <crypticline...@gmail.com>wrote:

> Hello,
>
> I am a R beginner and hoping to obtain some hints or suggestions about
> using permutations to sort a data set I have.
>
> Here is an example dataset:
>
>
> Ind1   11  00   12  15  28
> Ind2  21 33 22 67 52
> Ind3  22 45 21 22 56
> Ind4  11  25   74  77  42
> Ind5  41 32 67 45 22
>
> This will be read into a variable using read.table.  What I want to do
> is permute these individuals and every time pick 3 individuals and
> write them to a new variable.  I want to do this 100 times so that in
> the end I will have 100 tables containing data for 3 individuals each.
>  The data (for individuals) itself is not to be permuted, rather the
> selection of individuals.
>
> I am guessing this is probably trivial to do.  But I would appreciate
> any advice on this matter.
>
> Thank you.
> Vikram
>
> ______________________________________________
> 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.
>

        [[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.

Reply via email to