[R-sig-ME] School Sampling

Daniel Ezra Johnson danielezrajohnson at gmail.com
Wed Jan 14 19:00:07 CET 2009


>> 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

is it

> new <- subset(z,school%in%school.sample)

that gives you the result you want?




More information about the R-sig-mixed-models mailing list