R/stratsample.R

Defines functions stratsample

Documented in stratsample

stratsample<-function(strata, counts){
	strata<-as.character(strata)
	n<-length(strata)
	rval <- integer(sum(counts))
	allrows<-1:n
	j<-0
	for(i in 1:length(counts))	{
		thisstrat<-names(counts)[i]
	   rval[j+(1:counts[i])]<-sample(allrows[strata==thisstrat],counts[i])
	   j<-j+counts[i]
	}
	rval
	}

Try the survey package in your browser

Any scripts or data that you put into this service are public.

survey documentation built on July 19, 2021, 9:06 a.m.