title: Data table dcast column headings
body: <p>I have a data table of the form</p>
  
  <pre><code>ID  REGION  INCOME_BAND RESIDENCY_YEARS
  1   SW  Under 5,000 10-15
  2   Wales   Over 70,000 1-5
  3   Center  15,000-19,999   6-9
  4   SE  15,000-19,999   15-19
  5   North   15,000-19,999   10-15
  6   North   15,000-19,999   6-9
  </code></pre>
  
  <p>created by</p>
  
  <pre><code>exp = data.table(
    ID = c(1,2,3,4,5,6),
    REGION=c("SW", "Wales", "Center", "SE", "North", "North"),
    INCOME_BAND = c("Under ?5,000", "Over ?70,000", "?15,000-?19,999", "?15,000-?19,999", "?15,000-?19,999","?15,000-?19,999"),
    RESIDENCY_YEARS = c("10-15","1-5","6-9","15-19","10-15", "6-9"))
  </code></pre>
  
  <p>I would like to transform this to </p>
  
  <p><img src="https://i.stack.imgur.com/mXEsw.jpg" alt="Example of the result of any data table manipulation"></p>
  
  <p>I've managed to perform the majority of the work with dcast:</p>
  
  <pre><code>exp.dcast = dcast(exp,ID~REGION+INCOME_BAND+RESIDENCY_YEARS, fun=length,
    value.var=c('REGION', 'INCOME_BAND', 'RESIDENCY_YEARS'))
  </code></pre>
  
  <p>However I need some help creating sensible column headings.
  Currently I have</p>
  
  <blockquote>
    <p>["ID"<br>
    "REGION.1_Center_?15,000-?19,999_6-9"<br>
    "REGION.1_North_?15,000-?19,999_10-15"<br>
    "REGION.1_North_?15,000-?19,999_6-9"<br>
    "REGION.1_SE_?15,000-?19,999_15-19"             "REGION.1_SW_Under
    ?5,000_10-15"                "REGION.1_Wales_Over ?70,000_1-5"<br>
    "INCOME_BAND.1_Center_?15,000-?19,999_6-9"<br>
    "INCOME_BAND.1_North_?15,000-?19,999_10-15"<br>
    "INCOME_BAND.1_North_?15,000-?19,999_6-9"<br>
    "INCOME_BAND.1_SE_?15,000-?19,999_15-19"<br>
    "INCOME_BAND.1_SW_Under ?5,000_10-15"<br>
    "INCOME_BAND.1_Wales_Over ?70,000_1-5"<br>
    "RESIDENCY_YEARS.1_Center_?15,000-?19,999_6-9" 
    "RESIDENCY_YEARS.1_North_?15,000-?19,999_10-15"
    "RESIDENCY_YEARS.1_North_?15,000-?19,999_6-9"<br>
    "RESIDENCY_YEARS.1_SE_?15,000-?19,999_15-19"<br>
    "RESIDENCY_YEARS.1_SW_Under ?5,000_10-15"<br>
    "RESIDENCY_YEARS.1_Wales_Over ?70,000_1-5"</p>
  </blockquote>
  
  <p>And I would like the column headings to be</p>
  
  <pre><code>ID  SW  Wales   Center  SE  North   Under 5,000 Over 70,000 15,000-19,999   1-5 6-9 10-15   15-19
  </code></pre>
  
  <p>Could anybody advise?</p>