I have two different data frame, in one of them I have the information id
, in the other I have the id
and a vector n
, I would like associate the values of n
to id
in the first dataframe.
for exemple:
df1 <-data.frame(
id = c(1,1,1,2,2,3,3,3,3)
)
df2 <- data.frame(
id = c(1,2,3),
n = c(5,9,8)
)
I would like as output:
df1:
id n
1 5
1 5
1 5
2 9
2 9
3 8
3 8
3 8
3 8