have the following data frames:
id1<-c(1,2,3,4,5)
spent<-c(10,20,30,40,50)
id2<-c(1,3,4)
x<-c(1,2,2)
df1<-data.frame(id1,spent)
df2<-data.frame(id2,x)
I need to find the ids in df1
which also exist in df2
and export all their information to a new data frame (let's say df3
). on this basis df3
should look as follow:
id1 spent
1 10
3 30
4 40
I would be thankful if you could help me with this problem.