Try this:

x <- c(2,5,9,4,5,6,7,8)
u <- replicate(20, sample(x, replace = TRUE))
t(u)

The first argument of replicate() is the number of times to iterate the
process.
I believe you'll find that it does indeed do random sampling; each row
represents
a nonparametric bootstrap sample of x. There are other ways of doing this;
one is

v <- matrix(sample(x, 160, replace = TRUE), ncol = 8, byrow = TRUE)

HTH,
Dennis

On Tue, Sep 28, 2010 at 2:03 PM, Michael Larkin <mlarkin@rsmas.miami.edu>wrote:

> I am trying to get R to pick random integers from my dataset (i.e.
> bootstrapping) with replacement.  However, my attempts at this have been
> unsuccessful.  Here is a basic example of what I am doing:
>
> I have a data vector of 8 integers (data= 2,5,9,4,5,6,7,8).  I used the
> sample function and it worked but it only repeated my values in the exact
> same order.  It did not randomly sample them.  Here is my code:
>
> sample(data, replace=TRUE)
>
> Any advice would be greatly appreciated.
>
> Mike
>
>
>
>
>
>
>        [[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.
>

	[[alternative HTML version deleted]]

