I have two dataframes with acession numbers, and I want to substitute the values in a single column acession dataframe with the values from the type column.
First dataframe:
ï..study.identifier Year source type strain sample identifier
21 15 2009 human DT8 DT8 ERS007592 C0110
22 75 2004 duck DT30 S06281-04 ERS015643 S06281-04
23 76 2009 duck DT30 S04178-09 ERS015644 S04178-09
24 81 2005 chicken DT36 S03433-05 ERS015648 S03433-05
25 95 1996 duck DT9 12342-1996 ERS015661 12342-1996
26 96 2001 duck DT9 4300-2001 ERS015662 4300-2001
code acession level1 level2 level3
21 5103_5_3 ERR024405 1 1 2
22 5391_2_7 ERR028639 1 1 2
23 5391_2_8 ERR028640 1 1 2
24 5505_1_1 ERR029213 1 1 2
25 5505_2_3 ERR029229 1 1 2
26 5505_2_4 ERR029230 1 1 2
Second dataframe:
ï..study.identifier Year source type strain sample
67 29 NA <NA> DT102 3193-1995 ERS015603
68 35 2001 pig DT108 547-2001 ERS015613
69 39 1999 pig DT104A 7302-1999 ERS015607
70 44 1996 cattle DT108 10984-1996 ERS015612
71 51 1998 pig DT120 4284-1995 ERS015619
72 61 1997 environment DT167 8721-1997 ERS015629
identifier code acession level1 level2 level3
67 3193-1995 5386_5_11 ERR028272 2 4 11
68 547-2001 5386_6_10 ERR028283 2 4 11
69 7302-199 5386_6_4 ERR028287 2 4 11
70 10984-1996 5386_6_9 ERR028292 2 4 11
71 4284-1995 5386_7_5 ERR028300 2 4 11
72 8721-1997 5386_8_4 ERR028311 2 4 11
Dataframe whose values should be substituted:
tree.tip.label
1 ERR028314
2 ERR028313
3 ERR028300
4 ERR028635
5 ERR028292
6 ERR028312
How do I achieve this in R?
I'm newish to R and I can't seem to find a source that's specific to my problem
bind df1 and df2 to one data frame. Add a column with the name of the data frame. Check with an ifelse statement your condition:
output:
data: