What's an elegant way (without additional packages) to "expand" a given data.frame
according to one of its columns?
Given:
df <- data.frame(values = 1:5, strings = c("e", "g", "h", "b", "c"))
more.strings <- letters[c(3, 5, 7, 1, 4, 8, 6)]
Desired outcome: A data.frame
containing:
5 c
1 e
2 g
NA a
NA d
3 h
NA f
So those values of df$strings
appearing in more.strings
should be used to fill the new data.frame
(otherwise NA).