[R] removing specific rows from array

Maas James Dr (MED) J.Maas at uea.ac.uk
Fri Sep 17 16:51:19 CEST 2010


I'm attempting to create an array of treatment comparisons for modelling data generation.  This involves comparison of one treatment (c2) with another (c3), relative to a common comparator (c1).

Attached code gives me the correct array but need to remove duplicates.  Duplicates relate only to c2 and c3
such that I need to remove 

r3 because c2 and c3 are same as r1 with c2 and c3 swapped 
r5 because c2 and c3 are same as r2 with c2 and c3 swapped 
r6 because c2 and c3 are same as r4 with c2 and c3 swapped
r9 because c2 and c3 are same as r7 with c2 and c3 swapped
r11 because c2 and c3 are same as r8 with c2 and c3 swapped
.
.
.

Any suggestions?

Thanks

Jim



> treats <- c("t0","t1","t2","t3") 
> (combs1 <- permutations(length(treats),3,treats))
      [,1] [,2] [,3]
 [1,] "t0" "t1" "t2"
 [2,] "t0" "t1" "t3"
 [3,] "t0" "t2" "t1"
 [4,] "t0" "t2" "t3"
 [5,] "t0" "t3" "t1"
 [6,] "t0" "t3" "t2"
 [7,] "t1" "t0" "t2"
 [8,] "t1" "t0" "t3"
 [9,] "t1" "t2" "t0"
[10,] "t1" "t2" "t3"
[11,] "t1" "t3" "t0"
[12,] "t1" "t3" "t2"
[13,] "t2" "t0" "t1"
[14,] "t2" "t0" "t3"
[15,] "t2" "t1" "t0"
[16,] "t2" "t1" "t3"
[17,] "t2" "t3" "t0"
[18,] "t2" "t3" "t1"
[19,] "t3" "t0" "t1"
[20,] "t3" "t0" "t2"
[21,] "t3" "t1" "t0"
[22,] "t3" "t1" "t2"
[23,] "t3" "t2" "t0"
[24,] "t3" "t2" "t1"
>


===============================
Dr. Jim Maas
University of East Anglia



More information about the R-help mailing list