title: comparing the value of the first column of two dataframe to find the index of the same values in R?
body: <p>what I wanted to do is to compare the first column of two data frame and find the indexes of the same value and assign the element of the second column of the first dataframe to the second dataframe : 
  please see the example :</p>
  
  <pre><code>datafranmeA          dataframeB
  
     id   number         id   
  1  1     45             1
  2  3     78             4
  3  5     67             12
  4  12    18             5
  5  4     44             8
  6  8      32
  7  13     41
  
  output : dataframeB
  
           id     number
       1    1      45
       2    4      44
       3    12     18
       4    5      67
       5    8      32
  </code></pre>
  
  <p>I use a two for loop and if to compare but it is really slow as my own data is really big , how should I speed it up ?</p>
  
  <pre><code>for (i in 1:length(A[,1])){
   for (j in 1:length(B[,1])){
     if (A[i,1]==B[j,1]) {
        B[j,2]=A[i,2]}}}
  </code></pre>
  
  <p>thank you in advance,</p>