Re: [R] New Sampling question

2010-11-18 Thread wangwallace
I spent the whole afternoon on it, but there is still no progress. I wish I could take some courses... :( -- View this message in context: http://r.789695.n4.nabble.com/New-Sampling-question-tp3047885p3049796.html Sent from the R help mailing list archive at Nabble.com. ___

Re: [R] New Sampling question

2010-11-18 Thread wangwallace
Hi, Mike, thank you very much!!:) the following two functions are really helpful, which I didn't even know. Actually, I searched the forum for something like this, but failed. Now I am still trying to make up my own functions. :) sample(a[,2],2) #randomly draw two numbers from a column sample(

Re: [R] New Sampling question

2010-11-18 Thread Mike Rennie
You could try writing a loop a<-data.frame(c(1:10),c(21:30)) M<-10 #number of iterations- scale up to 1000 once you get your sampling function working res<-NULL #place to store your results for i in (1:M) { ares<-sample(a[,2],1) res<-c(res, ares) } res It's up to you how to

Re: [R] New Sampling question

2010-11-18 Thread wangwallace
Also, I need some function at the end which would enable me to draw 1000 such random samples. thanks! :) -- View this message in context: http://r.789695.n4.nabble.com/New-Sampling-question-tp3047885p3048958.html Sent from the R help mailing list archive at Nabble.com. _

Re: [R] New Sampling question

2010-11-18 Thread Mike Rennie
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:

Re: [R] New Sampling question

2010-11-18 Thread wangwallace
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 wan

Re: [R] New Sampling question

2010-11-18 Thread Ista Zahn
This can of course be done, but before I make any attempt to do it I have to ask: why do you want this? On Wed, Nov 17, 2010 at 7:08 PM, wangwallace wrote: > > I have another question about drawing samples from a data frame. This might > sound really tricky. Let me use a data frame I have posted

[R] New Sampling question

2010-11-17 Thread wangwallace
I have another question about drawing samples from a data frame. This might sound really tricky. Let me use a data frame I have posted earlier as an example: SubIDCSE1 CSE2 CSE3 CSE4 WSE1 WSE2 WSE3 WSE4 1 6 5 6 2 6 22 4 2