select a random sample from a population

```
population <- 1:100 # list of candidates, 1 ... 100
sample.size <- 10 # size of desired sample
samp <- sample(population, size=sample.size) # desired random sample
sort(samp) # sorted sample
```

`## [1] 1 19 36 52 76 78 85 91 98 99`

randomly assign participants to groups

```
sample.size <- 10
n.groups <- 3
n.population <- n.groups * sample.size
population <- 1:n.population # list of candidates, 1 ... 30
samp <- sample(population, size=n.population) # permute the list
samp <- matrix(samp, nrow=n.groups) # format as matrix
samp # each row is a group
```

```
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
## [1,] 26 10 7 16 14 22 8 6 11 21
## [2,] 30 3 13 1 9 5 18 23 27 15
## [3,] 28 12 4 24 25 19 17 29 2 20
```

*Select a random sample of 5 students from the 24 Stat 204 students in this room. Do it again.*

SOLUTION:

*Randomly assign the 24 Stat 204 students in this room to two groups of 12 students each. Do it again.*

SOLUTION: