Re: [R] Reconstruct a dataset

2009-12-15 Thread Lisa
Thanks a lot for your help. As I mentioned in my second subscription, my problem is not generating the random number, but rewriting the original dataset based on the sets of random number, or indices. Lisa Lisa wrote: > > Dear all, > > I have a dataset that looks like this: > > inividual

Re: [R] Reconstruct a dataset

2009-12-15 Thread Gray Calhoun
Hi Lisa, Look up indexing and random number generation. c(0,0,1,1) is not a random number. You can use sample to generate a random index, and index the dataset. I think that if you read the help pages (ie ?sample), you'll be able to use the code I sent you to get your results (I'll reproduce i

Re: [R] Reconstruct a dataset

2009-12-15 Thread Lisa
Supplement to my problem I know how to generate the random numbers, but I am not sure how to rewrite the dataset. In my example, for the first set of random number, rn1 <- c(0, 0, 1, 1), only the last two numbers are “1”s, not zeros, so I select the individual 3 and individual 4 from y original

[R] Reconstruct a dataset

2009-12-15 Thread Lisa
Dear all, I have a dataset that looks like this: inividual var1 var2 … 1 1 1 … 2 1 2 … 3 2 1 … 4 2 2 … … … … … I will random sample 2 individuals from this dataset based on a set of random