Hi Wallace, Have you tried playing with sample()? Note that you can apply this function both to whole dataframes, as well as specific items within a vector. If you play with applying the function to different ways of indexing your sample data, you will likely arrive at your solution.
for example: a<-data.frame(c(1:10),c(21:30)) sample(a[,2],2) #randomly draw two numbers from a column sample(a[2,],2) #randomly draw two numbers from a row a[sample(nrow(a),5,replace=T),] #ranomly draw four whole rows with replacement You may also find subet() helpful, based on your description. HTH, Mike On Thu, Nov 18, 2010 at 9:43 AM, wangwallace <talentt...@gmail.com> wrote: > > Dear Ista Zahn-2, > > If you can give me some advice, I really appreciate it. I have been working > on it for days. it seems hard for some novice of R like me to write > flexible > functions myself. > > This is for my dissertation. CSE and WSE are two scales of the same > construct. The sampling strategy I wanted above allows me check how the > items of these two scales vary within person and across person. > > Also, I added another rule: draw 1000 random samples... > > Again, Thanks! > > Wallace > -- > View this message in context: > http://r.789695.n4.nabble.com/New-Sampling-question-tp3047885p3048948.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > -- Michael Rennie, Research Scientist Fisheries and Oceans Canada, Freshwater Institute Winnipeg, Manitoba, CANADA [[alternative HTML version deleted]] ______________________________________________ R-help@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.