title: Replacing column headers with matched variables from another dataframe
body: <p>I have a data frame with around 50 entries and 2 columns - long list of short question names and corresponding long question names:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>variable_short</th>
  <th>variable_long</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>cat</td>
  <td>Do you have a cat?</td>
  </tr>
  <tr>
  <td>col</td>
  <td>Is blue your favourite colour?</td>
  </tr>
  <tr>
  <td>stress</td>
  <td>Are you stressed at work?</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>This is the summary of questions used in a survey. The survey responses are in a separate dataframe containing the column names which are the variables in variable_short -</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>person.id</th>
  <th>cat</th>
  <th>col</th>
  <th>stress</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2567</td>
  <td>1</td>
  <td>0</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I am trying to create a new dataframe with only the 10 questions I need from 50 and the corresponding survey responses along with the person id. What I am struggling with replacing the short question format in the survey data with the corresponding long question format from the variables data frame. Ideally something like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>person.id</th>
  <th>Do you have a cat?</th>
  <th>Are you stressed at work?</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2567</td>
  <td>1</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I started to subset to get the variables to the ones I need:</p>
  <pre><code>new &lt;- subset(variables, variable_short %in% c('cat', 'stress'), select = c('variable_short', 'variable_long'))
  </code></pre>
  <p>It reorders the variables so I can't go by the order and I assumed this isn't the most efficient way to do it incase variable order changes. I can rename column headings but I am not familiar yet with matching especially matching corresponding variable to a header.</p>
  <p>I am completely stuck right now so any help will be appreciated. Thank you so much.</p>