[R] sample from a list of names for random groups

kjetil brinchmann halvorsen kjetil at entelnet.bo
Mon Jun 30 23:26:49 CEST 2003


On 30 Jun 2003 at 17:11, Daniele Medri wrote:

You should really try to specify better what you want. Lets try

names # character vector with your names
m <- length(names)
n1 <- 5
n2 <- 10
muestra <- sample(names, m, replace=FALSE)
muestra1 <- muestra[1:n1]
muestra2 <- muestra[(n1+1):(n1+n2)]

Is this what you want?

Kjetil Halvorsen



> 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
> -- 
> Daniele Medri
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list