[R] Randomly shuffle an array 1000 times

2010-10-18 Thread Peter Francis
Dear List, I have a table i have read into R: NameYes/No John0 Frank 1 Ann 0 James 1 Alex1 etc - 800 different times. What i want to do is shuffle yes/no and randomly re-assign them to the name. I have used sample() and permute(), however there is no way to do

Re: [R] Randomly shuffle an array 1000 times

2010-10-18 Thread Steve Lianoglou
Hi, On Mon, Oct 18, 2010 at 7:37 AM, Peter Francis peterfran...@me.com wrote: Dear List, I have a table i have read into R: Name    Yes/No John    0 Frank   1 Ann             0 James   1 Alex    1 etc  - 800 different times. What i want to do is shuffle yes/no and randomly

Re: [R] Randomly shuffle an array 1000 times

2010-10-18 Thread Dennis Murphy
Hi: One way to permute your sample 1000 times is to use the r*ply() function from the plyr package. Let s denote your original vector, randomly generated as follows: s - rbinom(800, 0.6) # simulates your Yes/No vector library(plyr) u - raply(1000, sample(s))# generates a 1000 x

Re: [R] Randomly shuffle an array 1000 times

2010-10-18 Thread Dennis Murphy
Always fun to follow up your own posts The replicate() line should be v - replicate(1000, sample(s)) # generates an 800 x 1000 matrix Sorry for the bandwidth waste... Dennis On Mon, Oct 18, 2010 at 6:55 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: One way to permute your sample