0

Imagine there are two data frames.

df1 has several thousands of observations and looks like this:

Num     Code
00001   1
00002   2
00003   3
00004   1
00005   1
...     ...

df2 is short and lists all codes available, giving them description:

Code    Code_name
1       Short
2       Medium
3       Long

I want new data frame to be like df1, but with code names attached:

Num     Code      Code_name
00001   1         Short
00002   2         Medium
00003   3         Long
00004   1         Short
00005   1         Short
...     ...

Found kind of same question only for Python. A better way is may be to create some kind of a loop... This seems to be an easy task by I am to newbie for R, would appreciate any help.

1 Answers1

1

use merge() from the base package

merge(df1, df2, by = 'Code', all.x=T, all.y=F)