# Re: [R] Complex sampling?

From: Daniel Nordlund <djnordlund_at_frontier.com>
Date: Wed, 09 Mar 2011 08:39:30 -0800

> -----Original Message-----
> From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org]
> On Behalf Of Hosack, Michael
> Sent: Wednesday, March 09, 2011 7:34 AM
> To: r-help_at_R-project.org
> Subject: [R] Complex sampling?
>
> R users,
>
> I am trying to generate a randomized weekday survey schedule that ensures
> even coverage of weekdays in
> the sample, where the distribution of variable DOW is random with respect
> to WEEK. To accomplish this I need
> to randomly sample without replacement two weekdays per week for each of
> 27 weeks (only 5 are shown).

This seems simple enough, sampling without replacement.

However,
> I need to sample from a sequence (3:7) that needs to be completely
> depleted and replenished until the
> final selection is made. Here is an example of what I want to do,
> beginning at WEEK 1. I would prefer to do
> this without using a loop, if possible.
>
> sample frame: [3,4,5,6,7] --> [4,5,6] --> [4],[1,2,3,(4),5,6] -->
> [1,2,4,5,6] --> for each WEEK in dataframe

OK, now you have me completely lost. Sorry, but I have no clue as to what you just did here. I looks like you are trying to describe some transformation/algorithm but I don't follow it.

>
> Randomly sample 2 DOW_NUM without replacement from each WEEK ( () = no two
> identical DOW_NUM can be sampled
> in the same WEEK)
>
> sample = {3,7}, {5,6}, {4,3}, {1,5}, --> for each WEEK in dataframe
>

So, are you sampling from [3,4,5,6,7], or [1,2,4,5,6], or ...? Can you show an 'example' of what you would like to end up given your data below?

Dan

Daniel Nordlund
Bothell, WA USA

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 09 Mar 2011 - 16:44:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Mar 2011 - 17:50:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.