>From the way you describe it, I'd wager that you could probably use the
sample function.  For Example:

> group  = c("a","b","c","d","e","f","g","h","i","j")
> sample(group,length(group),replace=FALSE)
 [1] "h" "j" "g" "f" "d" "i" "e" "b" "a" "c"

but if you change replace to be TRUE

> sample(group,length(group),replace=TRUE)
 [1] "j" "h" "e" "d" "i" "a" "j" "h" "e" "b"

for more information check out the help file for sample

?sample

A

-- 
Adrienne Wootten
Graduate Research Assistant
State Climate Office of North Carolina
Department of Marine, Earth and Atmospheric Sciences
North Carolina State University


On Tue, Nov 30, 2010 at 12:45 PM, Emma Moran <emma.r.mo...@gmail.com> wrote:

> Hello,
>
> I am trying to write a function that first requires randomly sampling items
> from a set of factors. I need to be able to sample from that same set of
> factors, but exclude the ones that have already been sampled previously.
> For
> example, suppose I have a set of items a-j (a,b,c,d,e,f,g,h,i, and j) and
> randomly sample a, c, and f from that group. How do I sample again from the
> larger group (a-j) but exclude the items (a,c,f) that I have already
> sampled. I want this to be a function, so I don't want to just manually
> exclude a,c, and f.
>
> Thanks!
>
> --
> Emma Moran
> Washington University in St Louis
> Biology Department
> McDonnell Hall Rm 419
> One Brookings Drive, St. Louis, MO 63130
> emo...@wustl.edu
>
>        [[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]]

______________________________________________
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