title: R- find matching columns in two data frames for t-test statistics (R beginner)
body: <p>I would like to perform a two-sample t-test on my data within R.
  Given two high-dimensional data frames, I need to somehow loop through matching columns (String colnames() in header) over all rows and perform the test for each column pair - one from df1 and df2, respectively. The problem is that the columns from the data frames are not in right order, i.e. col1 form df1 doesn't match col1 from df2, and df2 has additional columns that don't exist in df1. I've never used R for such tasks and I wonder if there is a fast and handy solution to find matching column pairs in the data frames for the t-test.</p>
  
  <p>I thought about for-loops but I think this would be very inefficient for large data frames.</p>
  
  <p>Thank you in advance for any help.</p>
  
  <p><strong>*EDITED-------Two small example dataframes, df1 and df2--------------------------------</strong></p>
  
  <p>****df1****</p>
  
  <pre><code>"Row\Column"    "A2"    "A1"    "A4"    "A3"
  "id_1"           10      20      0       40
  "id_2"           5       15      25      35
  "id_3"           8       0       12      16
  "id_4"           17      25      0       40
  </code></pre>
  
  <p>****df2****</p>
  
  <pre><code>"Row\Column"    "A3"    "A8"    "A5"    "A6"    "A1"    "A7"    "A4"    "A2"
  "id_1"           0       2       0       4       0       1       2       3
  "id_2"           1       5       8       3       4       5       6       7
  "id_3"           2       10      6       9       8       9       10      11
  "id_4"           7       2       10      2       55      0       0       0
  "id_5"           0       1       0       0       9       1       3       4
  "id_6"           8       0       1       2       7       2       3       0  
  </code></pre>
  
  <p>Matching columns are nothing but the columns names in df1 matching with the columnsnames in df2. 
  For example
  Two matching columns in df1 and df2 are e. g. "A1" and "A1", "A2" and "A2" ... you get the idea...</p>