On Wed, Feb 1, 2012 at 11:18 PM, Elena Guijarro
<elena.guijarro at vi.ieo.es> wrote:> Dear all,
>
> I have to select 122 stratified random samples from a population of
> ?>3900 cells. I have 41 strata and I ?have to draw a different number of
> samples from them(between 2 and 8).
>
> I have tried to apply the funtion strata following the instruction in
> the manual:
>
> strata(dataframe, stratanames=NULL, size, method=c("srswor"),
> pik,description=TRUE)
>
> but I get the error message
>
> Error in data.frame((1:nrow(data))[srswor(size, nrow(data)) == 1],
rep(size/nrow(data), ?:
> ? arguments imply differing number of rows: 3, 122
>
> My stratanames and size vectors have the same length, 41 (the number of
strata), and 122 is the number of samples I need. The size vector is sorted in
the order the strata have in the dataframe (dim 3960 8).
You specified stratanames=NULL, which is not documented to work, and
doesn't seem to work on examples I tried.
> names(dataframe)
> [1] "lond" ? ? ? ?"latd" ? ? ? ?"stratanames"
"cell" ? ? ? ?"lat" ? ? ? ? "lon" ? ? ? ?
"div" ? ? ? ? "ID_unit"
Try specifying stratanames="stratanames", which is what the
documentation and examples seem to imply.
-thomas
--
Thomas Lumley
Professor of Biostatistics
University of Auckland