Let say we have the following matrices or data frames dyad_1 and dyad_2:
dyads_0 <- gtools::permutations(n=16,v=c(1:16), r=2)
dyad_1<- NULL
for (i in c(1,3:16)){
dyads1 <-NULL
dyads1 <- gtools::permutations(n=4,v=c(i,17:19), r=2)
dyad_1 <- rbind(dyad_1,dyads1[-c(5,6,8,9,11,12),])
}
dyad_1<- rbind(dyads_0,dyad_1)
dyad_2<- gtools::permutations(n=19,v=c(1:19), r=2)
now it is clear that dyad_1 is a subset of dyad_2. I want to remove those rows in dyad_2 which is similar to dyad_1. In other words, I want to extract dyad_1 from dyad_2. Could you please let me know if there is an efficient way to do that? Thanks!
update: The generalization of this is also very important for me: that is, now assume we have dyad_2 with four columns:
dyad_2$V0 <- rep(0, nrow(dyad_2))
dyad_2$V0 [120] <- 1
dyad_2$V4 <- rnorm(nrow(dyad_2)) .
Now my aim is to remove the complete rows of dyad_2 whose elements in the columns V1 and V2 are the same as rows in dyad_1.
As clarification a simple example comes as follows:
Assume dyad_2 is
V0 V1 V2 V4
0 1 2 0.1
0 1 3 0.2
1 2 1 0.15
0 2 3 0.001
0 3 1 0
0 3 2 0.1
0 10 5 0.9
Assume dyad_1 is
V1 V2
1 2
2 3
3 2
10 5
the output should be as follows:
V0 V1 V2 V4
0 1 3 0.2
1 2 1 0.15
0 3 1 0
This is just an example for clarification and differs from the abovementioned codes.
I would be very grateful if you could give me your solution as I got stuck already.