Here is some R code that should help you do HW assignment 6. You should read the details of assignment 6 in the syllabus carefully before looking at this code.
The only code you will have to change is the last 12 lines in the window which are those after the line set.seed(2004). Of course you will have to consider various designs. It will probably be helpful to look at other functions of popx as possible designs.