title: Create standard data.table columns given multiple inputs
body: <p>I am writing a function which re-write the column names in order to output the data.table in a standard. The inputs are user-provided data.tables which might differ by several names. </p>
  
  <p>Here is the format which should be the output of all input data.tables:</p>
  
  <pre><code>length    width    height    weight
  </code></pre>
  
  <p>The input data.tables may look like, e.g. </p>
  
  <pre><code>input_dt = data.table(
    length = 194,
    wide = 36,
    tall = 340,
    kilogram = 231.2
  )
  </code></pre>
  
  <p>My function would take this data.table (or data.frame) as an input, and change the columns, outputting this data.table:</p>
  
  <pre><code>length    width    height    weight
  194       36      340     231.2
  </code></pre>
  
  <p>I've created a <code>key</code> for the function which would check possible names:</p>
  
  <pre><code>key = list(
      length = c('long'),
      width = c('girth', 'WIDTH', 'wide'),
      height = c('tall', 'high'),
      weight =  c('Weight', 'WEIGHT', 'kilogram', 'pound', 'kilograms', 'pounds')
  )
  </code></pre>
  
  <p>Now, within the function, I can check the input column names of <code>input_dt</code> to check whether they need to be changed by checking the intersection:</p>
  
  <pre><code>&gt; intersect(names(input_dt), unlist(key))
  [1] "wide"     "tall"     "kilogram"
  </code></pre>
  
  <p>And then change these appropriately. My question is:</p>
  
  <p>Writing this custom function would be full of for-loops, and quite inefficient. Are there other more data.table-friendly solutions available, given a custom "key" of values? </p>