try sampling the 'indices' and then using them to get the subset:
> x.in
dirn county year exp exp.wave r3
1 43901 Cuyahoga 2006 0 0 56
2 49098 Pickaway 2006 0 0 77
3 44164 Portage 2006 0 0 85
4 44610 Wayne 2006 1 1 76
5 45120 Wayne 2006 0 0 82
6 49593 Scioto 2006 1 1 89
7 46516 Crawford 2006 0 0 75
8 50054 Summit 2006 0 0 92
9 48231 Lucas 2006 0 0 79
10 49908 Stark 2006 0 0 90> x.in[sample(seq(nrow(x.in)), 5),]
dirn county year exp exp.wave r3
8 50054 Summit 2006 0 0 92
6 49593 Scioto 2006 1 1 89
1 43901 Cuyahoga 2006 0 0 56
2 49098 Pickaway 2006 0 0 77
10 49908 Stark 2006 0 0 90>
On 3/8/07, Anirudh V. S. Ruhil <ruhil@ohio.edu>
wrote:>
> Folks,
>
> I have a dataframe (snippet shown below).
>
> > demo.df[1:10, 1:6]
> dirn county year exp exp.wave r3
> 1 43901 Cuyahoga 2006 0 0 56
> 2 49098 Pickaway 2006 0 0 77
> 3 44164 Portage 2006 0 0 85
> 4 44610 Wayne 2006 1 1 76
> 5 45120 Wayne 2006 0 0 82
> 6 49593 Scioto 2006 1 1 89
> 7 46516 Crawford 2006 0 0 75
> 8 50054 Summit 2006 0 0 92
> 9 48231 Lucas 2006 0 0 79
> 10 49908 Stark 2006 0 0 90
>
> If I need to draw all possible samples of size n (where n = 30, n = 50,
> and
> so on), and run a particular linear model on each subsample of a specific
> size, then tabulate coeffs on specific covariates for subsequent
> manipulation/graphical representation, what would be the best means of
> doing so?
>
> "sample.1 <- sample(demo.df, 30, replace = FALSE)"
>
> doesn't work; it just gives me the entire population in demo.df. What
am I
> missing?
>
> thanks in advance
>
> Ani
>
> Anirudh V. S. Ruhil, Ph.D.
> Sr. Research Associate
> Voinovich Center for Leadership and Public Affairs
> Ohio University
> Building 21, The Ridges
> Athens, OH 45701-2979
> Tel: 740.597.1949 | Fax: 740.597.3057
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
[[alternative HTML version deleted]]