Best merge or join function in r -


this question has answer here:

i have 2 dataframes df1 , df2. both have common identifier column.

df1 has unique lines each identifier. has identifier values not in df2.

df2 has multiple lines each identifier value.

i want merge 2 preserve number of rows of df2, map (repeating) relevant id rows df1 df2.

is best use merge or join or else? arguments?

thanks :)

without input data, hard provide working code. but, dplyr package's join functions super efficient kinds of joins.

in case, can try like:

library(dplyr) newdf <- left_join(df1, df2) 

this keep id's in df1, while retaining duplicate rows in df2 long common column filed matches.


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -