There is dataset
data=structure(list(x1 = structure(c(1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L), .Label = c("q",
"r", "w"), class = "factor"), x2 = structure(c(2L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L
), .Label = c("e", "w"), class = "factor"), x3 = structure(c(1L,
1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L,
2L, 2L, 2L), .Label = c("e", "q", "r"), class = "factor"), var = c(34L,
35L, 34L, 34L, 34L, 34L, 35L, 34L, 34L, 34L, 34L, 35L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L), act = c(1L, 1L, 1L, 1L, 1L, 0L,
0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L)), .Names = c("x1",
"x2", "x3", "var", "act"), class = "data.frame", row.names = c(NA,
-20L))
by columns x1, x2, x3 we have three groups
q w e
w e r
r e q
There is anothere dataset. It structure
dat= structure(list(x1 = structure(1:2, .Label = c("q", "r", "w"), class = "factor"),
x2 = structure(c(2L, 1L), .Label = c("e", "w"), class = "factor"),
x3 = structure(1:2, .Label = c("e", "q", "r"), class = "factor")),
class = "data.frame", row.names = c(NA,-2L), .Names = c("x1", "x2", "x3"))
I.E.
x1 x2 x3
1 q w e
2 r e q
How do I compare the datasets data
and dat
In the way that, in dataset data
were only observation for groups indicated in dataset dat
I.E. output
x1 x2 x3 var act
q w e 34 1
q w e 35 1
q w e 34 1
q w e 34 1
q w e 34 1
r e q 34 1
r e q 34 1
r e q 34 1
r e q 34 1
r e q 34 1
NOTE: this is testdata. There are many groups.