Friends,

I thought this question more appropriate here instead of the R-Help. Suppose that I just want to sample schools in a multilevel dataset, but I want to sample some schools more than once. I tried something like the following, but it is not sampling everyone in a given school (just the first person). Any ideas? Also, feel free to comment about the appropriateness of sampling schools. We are trying to do some simulation work related to power in the level-2 sample size and the degree of missingness of data at this level.

Thanks,
Kyle

> z<-data.frame(school=factor(rep(1:5, each=2)), score=21:30)
> school.sample<-sample(levels(z$school), 3, replace=T)
> school.sample
[1] "5" "1" "2"
> new<-subset(z, school==school.sample)
Warning messages:
1: In is.na(e1) | is.na(e2) :
  longer object length is not a multiple of shorter object length
2: In `==.default`(school, school.sample) :
  longer object length is not a multiple of shorter object length
> new
   school score
2       1    22
3       2    23
10      5    30

*********************************************************
Dr. J. Kyle Roberts
Department of Teaching and Learning
Annette Caldwell Simmons School of Education
   and Human Development
Southern Methodist University
P.O. Box 750381
Dallas, TX  75275
214-768-4494
http://www.hlm-online.com/
*********************************************************


	[[alternative HTML version deleted]]


