title: Filter matching cases from different datasets in R
body: <p>I have a few time-series datasets, e.g., GDP growth, FDI and education over the period 1960-2000. Identifying (unique) variable in all datasets is <code>country_name</code>. Some countries are present in one dataset but missing in another. I would like to select (filter) the countries that are present in all datasets. How this can be done in <code>R</code>?<br>
  <code>data.frame</code>'s look as follows:</p>
  
  <pre><code>FDI
  country       2001        2002       2003        2004       2005
     A    -0.4769080 -0.89159864 -0.2140591 -0.93326470 -0.1726757
     B    -0.1246048  0.09929738  1.0522747  0.08724465 -0.9064532
     C     1.9592917  1.06080273  0.5316807 -0.94478259 -1.1342767
     E    -1.0585177  0.58981906  0.5210434 -0.81212231  0.7862898
  
  GDP growth
  country       2001        2002       2003       2004        2005
     A    0.06323898  0.08537586  0.8982821 -1.3635704  0.45569153
     B    1.19848687  1.41307212  0.3358561 -0.8368255  0.22987821
     D    1.13491209 -0.98472341  0.7545730 -0.3595143  0.07172593
     E    0.83561289  0.51227238 -0.1377516  1.8841489 -0.94319505
  </code></pre>
  
  <p>I need to select matching cases A, B and E, and put everything in long format, preferably using <code>reshape2</code>.<br><br>
  Output should look like (excluding C and D because they are not in both datasets):</p>
  
  <pre><code>country    year      FDI            GDP growth
    A        2001   -0.4769080        0.06323898
    A        2002   -0.89159864       0.08537586
    A        2003   -0.2140591        0.8982821
    ... ...
    B        2001   -0.1246048        1.19848687
    ... ...
    ... ...
    E        2005    0.7862898       -0.94319505
  </code></pre>