So I've been puzzling on this for a week or so and don't see any elegant way to do it. I'd imagine there's a nifty way to do it using ddply() in conjunction with some melt() tools to get it all in one data frame (or just possibly mapply() after converting the "iN" factors to characters to make sure they get matched properly), but I'm going to try to bump it to see if anyone else can give you a good solution. Michael
On Fri, Sep 30, 2011 at 7:18 AM, Metronome123 <lars.hulzebos at gmail.com> wrote:
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.
______________________________________________ R-help at 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.