[R] Permutations of configurations on multiple columns

Metronome123 lars.hulzebos at gmail.com
Fri Sep 30 13:18:32 CEST 2011


Michael Weylandt wrote:
> 
> I'm not entirely sure how these two objects are related. Perhaps give a
> little more information on the transform and we can help with
> implementation...
> 

Ok, I have got 2 matrices [P,I] and [I,E].

testcontents [P,I]:
structure(list(P = structure(c(1L, 1L, 1L, 2L, 2L, 3L, 3L), .Label = c("p1", 
"p2", "p3"), class = "factor"), I = structure(c(1L, 2L, 3L, 1L, 
4L, 5L, 6L), .Label = c("i1", "i2", "i3", "i4", "i5", "i6"), class =
"factor")), .Names = c("P", 
"I"), class = "data.frame", row.names = c(NA, -7L))

testcontents [I,E]:
structure(list(I = structure(c(1L, 1L, 2L, 3L, 3L, 4L, 5L, 6L, 
6L), .Label = c("i1", "i2", "i3", "i4", "i5", "i6"), class = "factor"), 
    E = structure(1:9, .Label = c("e11", "e12", "e21", "e31", 
    "e32", "e41", "e51", "e61", "e62"), class = "factor")), .Names = c("I", 
"E"), class = "data.frame", row.names = c(NA, -9L))

I want to create a matrix [P,C,E] where c is one of all unique vectors C
within P of one combination of I selected from all possible values in the
[I,E] matrix.
Note that for each i there can be a different number of e's. I tried to add
indices in the testcontent to make the aim more clear.

So the result of the [P,C,E] matrix should be something like:
structure(list(P = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L), .Label = c("p1", "p2"), class = "factor"), C =
structure(c(1L, 
1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 
6L, 6L, 6L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L), .Label = c("c11", 
"c12", "c13", "c14", "c21", "c22", "c23", "c24"), class = "factor"), 
    E = structure(c(1L, 3L, 4L, 2L, 3L, 4L, 1L, 3L, 5L, 2L, 3L, 
    5L, 1L, 6L, 7L, 8L, 2L, 6L, 7L, 8L, 1L, 6L, 7L, 9L, 2L, 6L, 
    7L, 9L), .Label = c("e11", "e12", "e21", "e31", "e32", "e41", 
    "e51", "e61", "e62"), class = "factor")), .Names = c("P", 
"C", "E"), class = "data.frame", row.names = c(NA, -28L))

Hopefully it is more clear now.

Cheers, Lars

--
View this message in context: http://r.789695.n4.nabble.com/Permutations-of-configurations-on-multiple-columns-tp3855495p3859499.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list