Skip to content

Random Sample with Unique function

4 messages · Krystyna Golabek, Uwe Ligges

#
In order to use stratified sampling, either try to implement it yourself 
or use the "sampling" package and its function strata() as in:

s1 <- strata(cc, stratanames="ID", size=rep(1, 20), method="srswr")

then you will get 1 observation for each ID. Note that it is not 
important to use "with replacement" in your case, since you only sample 
1 obervation for each stratum.

Uwe Ligges
Krystyna Golabek wrote:
#
You need to wrap it accordingly:

s1 <- cc[strata(cc, stratanames="ID", size=rep(1, 20), 
method="srswr")$ID_unit, ]

Uwe
Krystyna Golabek wrote:
>>