I have two data frames which are edge lists containing columns "source" and "target" as their first two columns and the second data frame includes a third column with edge attributes. The two data frames are not of the same length and I want (1) to retrieve the edges from one data frame that are not in the other and (2) to get the values from the second data frame for matching edges.
Example:
> A <- data.frame(source=c("v1", "v1", "v2", "v2"), target=c("v2", "v4", "v3", "v4"))
> B <- data.frame(source=c("V1", "V2", "v1", "V4", "V4", "V5"), target=c("V2", "V5", "V3", "V3", "V2", "V4"), variable=c(3,4,0,2,1,0))
> A
source target
1 v1 v2
2 v1 v4
3 v2 v3
4 v2 v4
> B
source target variable
1 V1 V2 3
2 V2 V5 4
3 v1 V3 0
4 V4 V3 2
5 V4 V2 1
6 V5 V4 0
desirable outcome (1):
source target
1 V2 V5
2 V1 V3
3 V4 V3
4 V5 V4
desirable outcome (2):
source target variable
1 V1 V2 3
2 V2 V4 1
How can this be achieved with R?