I'm trying to figure out how to use merge() to update a data frame.
Take for example the data frame foo
foo <- data.frame(index=c('a', 'b', 'c', 'd'), value=c(100, 101, NA, NA))
Which has the following values
index value
1     a   100
2     b   101
3     c    NA
4     d    NA
And the data frame bar
bar <- data.frame(index=c('c', 'd'), value=c(200, 201))
Which has the following values:
 index value
1     c   200
2     d   201
When I run the following merge() function to update the values for c and d
merge(foo, bar, by='index', all=T)
It results in this output:
 index value.x value.y
1     a     100      NA
2     b     101      NA
3     c      NA     200
4     d      NA     201
I'd like the output of merge() to avoid the creation of, in this specific example, of value.x and value.y but only retain the original column of value  Is there a simple way of doing this?
 
     
     
     
     
     
     
     
     
     
    