Avoid recycling when merging with R Data Table
What you want to do is join-like behaviour that is among others documented here: 
joins and others

To make things readable here a version with dplyr

ex1 &lt;- data.frame(id = 1:10, name = replicate(10, paste(sample(letters[1:5], size = 2), collapse = "")))

ex2 &lt;- data.frame(otherinfo = (1:5)+50, othername = replicate(5, paste(sample(letters[1:5], size = 2), collapse = "")))

dplyr::left_join(ex1, ex2, by = c(name = "othername"))

   id name otherinfo
1   1   ac        NA
2   2   ac        NA
3   3   ab        NA
4   4   da        53
5   5   ab        NA
6   6   cb        NA
7   7   eb        NA
8   8   de        NA
9   9   ad        NA
10 10   ec        52