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 prove helpful:

POP_SIZE = 6
LEN = 8

pop=create_pop_2(POP_SIZE, LEN)

print(pop)
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]    0    1    0    1    1    0    0    1
[2,]    0    0    0    0    0    0    0    0
[3,]    1    1    0    0    1    0    0    0
[4,]    0    0    0    0    0    0    0    1
[5,]    0    0    1    1    0    0    1    0
[6,]    1    0    0    0    0    0    1    0
[7,]    0    0    0    0    0    0    0    0
[8,]    0    0    0    0    0    0    0    0
[9,]    0    0    0    0    0    0    0    0
[10,]    0    0    0    0    0    0    0    0
[11,]    0    0    0    0    0    0    0    0
[12,]    0    0    0    0    0    0    0    0

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.

(2) be able to shuffle the rows only, and

I have suggested that shuffling by way of a random selection of an external index:

> pop=create_pop_2(POP_SIZE, LEN)
[1] 48
> pop
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
 [1,]    1    1    0    0    1    0    1    1
 [2,]    1    0    1    0    0    0    1    0
 [3,]    1    1    0    1    0    1    0    0
 [4,]    0    0    0    0    1    0    0    0
 [5,]    1    0    0    1    1    1    1    1
 [6,]    1    1    0    0    0    0    0    0
 [7,]    0    0    0    0    0    0    0    0
 [8,]    0    0    0    0    0    0    0    0
 [9,]    0    0    0    0    0    0    0    0
[10,]    0    0    0    0    0    0    0    0
[11,]    0    0    0    0    0    0    0    0
[12,]    0    0    0    0    0    0    0    0

> dx <- sample(1:nrow(pop), nrow(pop) )
> dx
 [1] 12 10  8  9  3  1  6 11  5  7  4  2
> pop[dx,]
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
 [1,]    0    0    0    0    0    0    0    0
 [2,]    0    0    0    0    0    0    0    0
 [3,]    0    0    0    0    0    0    0    0
 [4,]    0    0    0    0    0    0    0    0
 [5,]    1    1    0    1    0    1    0    0
 [6,]    1    1    0    0    1    0    1    1
 [7,]    1    1    0    0    0    0    0    0
 [8,]    0    0    0    0    0    0    0    0
 [9,]    1    0    0    1    1    1    1    1
[10,]    0    0    0    0    0    0    0    0
[11,]    0    0    0    0    1    0    0    0
[12,]    1    0    1    0    0    0    1    0

(3) be able to compare two copies of these objects
for equality and have it return True if only the rows have been shuffled.

I see two possible questions, the first easier (for me) than the second. Do you want to work on a copy with a known permutation of rows... or on a copy with an unknown ordering? In the first case I am unclear why you would not create an original and a copy, work on the copy, and compare with the original that is also sorted by the external index.


______________________________________________
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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
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.

Reply via email to