You could try writing a loop

a<-data.frame(c(1:10),c(21:30))

M<-10 #number of iterations- scale up to 1000 once you get your sampling
function working
res<-NULL #place to store your results
for i in (1:M)
     {
     ares<-sample(a[,2],1)
     res<-c(res, ares)
     }
res

It's up to you how to store your results- you can do it as a list if you
want, then you can get at each of your 1000 results. I've provided a simple
example where you just add each result to the end of your vector.

Note also that someone will also take issue with the way I'm assigning
results in the loop- I know I've seen it written elsewhere that this is not
a very elegant way of approaching the problem (particularly in terms of
efficiency), but it will work. I just can't recall the other way of doing
things off the top of my head- if someone else would like to chime in, be my
guest.

Mike



On Thu, Nov 18, 2010 at 9:46 AM, wangwallace <talentt...@gmail.com> wrote:

>
> Also, I need some function at the end which would enable me to draw 1000
> such
> random samples. thanks! :)
> --
> View this message in context:
> http://r.789695.n4.nabble.com/New-Sampling-question-tp3047885p3048958.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Michael Rennie, Research Scientist
Fisheries and Oceans Canada, Freshwater Institute
Winnipeg, Manitoba, CANADA

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