Entering edit mode
4.3 years ago
Ksandersen
▴
20
Hello All
I have two gene tables in R. I want to make some code, which can do the following.
- Take the genes in
Gene_Tabel1
and compare if they are present inGene_tabel2
- If The genes are present in
Gene_Tabel2
I want to add the information fromGene_Table2
into a new Table as shown inGene_Table3
I believe this could be done through a loop and some extra coding. However, I do not know exactly to produce this code (I am very new to coding).
Gene_Tabel1:
Gene
1 ENSDARG00000063908
2 ENSDARG00000070083
3 ENSDARG00000063911
4 ENSDARG00000099499
5 ENSDARG00000092553
6 ENSDARG00000056008
7 ENSDARG00000098355
8 ENSDARG00000088383
9 ENSDARG00000063924
10 ENSDARG00000068738
etc...
Gene_Tabel2:
Gene
1 ENSDARG00000102123 phtf2
2 ENSDARG00000114503 phtf21
3 ENSDARG00000070083 atp5f1b
4 ENSDARG00000098311 si:zfos-932h1.3
5 ENSDARG00000104839 mansc1
6 ENSDARG00000100143 Irp6
7 ENSDARG00000068738 dusp16
8 ENSDARG00000104049 crebl2
9 ENSDARG00000102226 gpr19
10 ENSDARG00000103095 tbk1
etc...
Gene_Tabel3:
Gene
1: ENSDARG00000070083 atp5f1b
2: ENSDARG00000068738 dusp16
I hope there is someone who can give me a helping hand.
Best Regards
Kristian Andersen
You should look into the
merge
function. That does exactly what you're looking for.Thanks for the hint. :) I figured out how to do the merging.
I used the following code:
Could you posible provide me with the coding? It doesn't seem to work for me?
Please read up on the documentation and show us what you've tried. Asking for exact code is not good etiquette.
Would linux commands work for you? AWK and grep?
Please do not supply users with code - it interferes with their learning.
Can you post some example data from both tables using
dput(head(Gene_Table1))
anddput(head(Gene_Table2))
?