How to mount a data.frame with identical elements from another two data frames.

Asked

Viewed 322 times

3

Hello,

I have two data.frames, each with 1 column. A data.frame has 3701 rows, while the other has more than 50,000 rows. What I want is this: assemble a data.frame that contains only the data.frame elements with 3701 lines that are present in the 50,000 lines. I’ve tried a lot, but I couldn’t get out of the corner.

1 answer

2


I’m not sure if that’s what you want, but I thought the following scenario:

df1<-data.frame(a=1:20) # Data frame com apenas 20 elementos
df2<-data.frame(b=11:50) # Data frame com 40 elementos
df3<-df2[which(is.element(df2$b,df1$a)),] # Seleciona os elementos do 
                                          # df2 que estão contidos no df1  

Browser other questions tagged

You are not signed in. Login or sign up in order to post.