I have a dataframe like this:
df = data.frame(id = c(1,1,3,4,4), stockoprice1 = c(3,4,2,45,1))
And a second like this:
df2 = data.frame(id = c(1,4), name = c("price1","price2"))
I would like to merge them in order to take results like this:
> dfexpected = data.frame(id = c(1,1,3,4,4), stockprice1 = c(3,4,2,45,1), name = c("price1","price1",NA,"price2","price2"))
> dfexpected
id stockprice1 name
1 1 3 price1
2 1 4 price1
3 3 2 <NA>
4 4 45 price2
5 4 1 price2
Which is the appropriate merge option?