Re: [R] 3 questions regarding matrix copy/shuffle/compares

2009-04-26 Thread Esmail
David Winsemius wrote: My understanding of the OP's request was for some sort of copy which did change when entries in the original were changed; the sort of behavior that might be seen in a spreadsheet that had a copy "by reference". You misunderstood (my phrasing wasn't probably the best)

Re: [R] 3 questions regarding matrix copy/shuffle/compares

2009-04-26 Thread hadley wickham
In that case, you would want a shallow copy, and you'd need to jump through a lot of hoops to do that in R. Hadley On Sun, Apr 26, 2009 at 10:35 AM, David Winsemius wrote: > My understanding of the OP's request was for some sort of copy which did > change when entries in the original were change

Re: [R] 3 questions regarding matrix copy/shuffle/compares

2009-04-26 Thread Esmail
hadley wickham wrote: I want to (1) create a deep copy of pop, I have already said *I* do not know how to create a "deep copy" in R. Creating a deep copy is easy, because all copies are "deep" copies. You need to try very hard to create a reference in R. Hi Hadley Right you are .. I discove

Re: [R] 3 questions regarding matrix copy/shuffle/compares

2009-04-26 Thread Esmail
David, Good news! It seems that R has deep copy by default. I ran this simplified test and it seems I can change 'pop' without changing the saved version. POP_SIZE = 4 LEN = 8 pop=create_pop_2(POP_SIZE, LEN) cat('printing original pop\n') print(pop) keep_pop = pop pop[1,1] = 99 cat('printing c

Re: [R] 3 questions regarding matrix copy/shuffle/compares

2009-04-26 Thread David Winsemius
My understanding of the OP's request was for some sort of copy which did change when entries in the original were changed; the sort of behavior that might be seen in a spreadsheet that had a copy "by reference". On Apr 26, 2009, at 11:28 AM, hadley wickham wrote: I want to (1) create a d

Re: [R] 3 questions regarding matrix copy/shuffle/compares

2009-04-26 Thread hadley wickham
>> I want to (1) create a deep copy of pop, > > I have already said *I* do not know how to create a "deep copy" in R. Creating a deep copy is easy, because all copies are "deep" copies. You need to try very hard to create a reference in R. Hadley -- http://had.co.nz/ _

Re: [R] 3 questions regarding matrix copy/shuffle/compares

2009-04-26 Thread David Winsemius
On Apr 26, 2009, at 9:43 AM, Esmail wrote: David Winsemius wrote: Yes. As I said before "I am going to refrain from posting speculation until you provide valid R code that will create an object that can be the subject of operations." The code I have provided works, here is a run that may

Re: [R] 3 questions regarding matrix copy/shuffle/compares

2009-04-26 Thread Esmail
David Winsemius wrote: Yes. As I said before "I am going to refrain from posting speculation until you provide valid R code that will create an object that can be the subject of operations." The code I have provided works, here is a run that may prove helpful: POP_SIZE = 6 LEN = 8 pop=cre

Re: [R] 3 questions regarding matrix copy/shuffle/compares

2009-04-26 Thread David Winsemius
On Apr 26, 2009, at 7:48 AM, Esmail wrote: Hello David, Let me try again, I don't think this was the best post ever I've made :-) Hopefully this is clearer, or otherwise I may break this up into three separate simple queries as this may be too long. > "==" is not an assignment operator in

Re: [R] 3 questions regarding matrix copy/shuffle/compares

2009-04-26 Thread Esmail
Hello David, Let me try again, I don't think this was the best post ever I've made :-) Hopefully this is clearer, or otherwise I may break this up into three separate simple queries as this may be too long. > "==" is not an assignment operator in R, so the answer is that it > would do neither.

Re: [R] 3 questions regarding matrix copy/shuffle/compares

2009-04-25 Thread David Winsemius
On Apr 26, 2009, at 12:28 AM, Esmail wrote: Hello all, I have the following function call to create a matrix of POP_SIZE rows and fill it with bit strings of size LEN: pop=create_pop_2(POP_SIZE, LEN) Are you construction a vector or a matrix? What are the dimensions of your matrix?

[R] 3 questions regarding matrix copy/shuffle/compares

2009-04-25 Thread Esmail
Hello all, I have the following function call to create a matrix of POP_SIZE rows and fill it with bit strings of size LEN: pop=create_pop_2(POP_SIZE, LEN) I have 3 questions: (1) If I did keep_pop[1:POP_SIZE] == pop[1:POP_SIZE] to keep a copy of the original data structure before