1

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
Cœur
  • 37,241
  • 25
  • 195
  • 267
memy
  • 229
  • 1
  • 2
  • 8

1 Answers1

0
df1 <- merge(df1, df2, by = c("id") )
timat
  • 1,480
  • 13
  • 17