I have two columns inside of a dataframe called df1
looking like this:
V1 V2
GENE A GENE E
GENE B GENE D
GENE C GENE A
GENE D GENE B
GENE E GENE C
and another dataframe called df2
like this:
Name ID Symbol
GENE A 1254 AKT
GENE B 1879 POU5F1
GENE C 5689 EGR1
GENE D 2385 JUN
GENE E 5687 MYC
The output I would like to have is the following:
NameSource SourceID NameTarget TargetID
AKT 1254 MYC 5687
POU5F1 1879 JUN 2385
EGR1 5689 AKT 1254
JUN 2385 POU5F1 1879
MYC 5687 EGR1 5689
I tried with the following syntax:
genes <- df1[which(df1$V1, df2$Symbol), ]
and with:
genes <- df1$V1 %in% df2$Symbol
But for some reason I cannot get the output I am expecting. Any ideas?
Exactly like that! Thank you so much!
Please post link to SO solution, as well here, for future reference