[R] sample from a list of names for random groups
Spencer Graves
spencer.graves at pdf.com
Mon Jun 30 18:20:44 CEST 2003
> n1 <- 2
> n2 <- 3
> (S <- sample(letters, n1+n2))
[1] "f" "a" "d" "n" "l"
> (S1 <- sample(S, n1))
[1] "l" "n"
> (S2 <- S[!is.element(S, S1)])
[1] "f" "a" "d"
>
hope this helps. spencer graves
Daniele Medri wrote:
> Dear R-users,
>
> I need to sample from a list of names (people) and create 2 random groups with
> unique item. Sure sample() function is a good point to start but I can't find
> example to solve my work.
>
> any tips? example?
>
> Thank
More information about the R-help
mailing list