title: Replace value of column based on other datatable columns
body: <p>I have three datatables created from the csv that are in this public bucket <a href="https://console.cloud.google.com/storage/browser/securitas" rel="nofollow noreferrer">https://console.cloud.google.com/storage/browser/securitas</a></p>
  
  <pre><code>data_total = "source_year", "state", "is_male", "child_race", "weight_pounds" with more than 1M rows
  race = (id_race=c(1,2,3,4,5,6,7,9,18,28,39,48),race=c("white","black","american indian","chinese","japanese","hawaiian","filipino","unknown/other","asian indian","korean","samoan","vietnamese"))
  sex = (id_sex=c(false,true), de_sex=c("female","male"))
  </code></pre>
  
  <p>I need to create a new datatable with the following columns:
  - State
  - total births for the 70's for each state
  - total births for the 80's for each state
  - total births for the 90's for each state
  - total births for the 00's for each state
  - race (text) with more births for the 70's for each state
  - race (text) with more births for the 80's for each state
  - race (text) with more births for the 90's for each state
  - race (text) with more births for the 00's for each state
  - total males for each state
  - total females for each state
  - avg weight in kgs for each state</p>
  
  <p>I create the data datatable with:</p>
  
  <pre><code>data_total = rbindlist(lapply(list.files(path=".", pattern="natalidad*"), data.table::fread , header = T, verbose = F, sep = ',', select = c("source_year", "state", "is_male", "child_race", "weight_pounds")))
  </code></pre>
  
  <p>and then the new datatables to later merge:</p>
  
  <pre><code>b70 = setnames(data_total[source_year %between% c(1970,1979), .N, keyby = state],"N","b70")
  b80 = setnames(data_total[source_year %between% c(1980,1989), .N, keyby = state],"N","b80")
  b90 = setnames(data_total[source_year %between% c(1990,1999), .N, keyby = state],"N","b90")
  b00 = setnames(data_total[source_year %between% c(2000,2010), .N, keyby = state],"N","b00")
  
  male = data_total[source_year %between% c(1970,2010), .(male=sum(is_male==TRUE)), keyby = state]
  female = data_total[source_year %between% c(1970,2010), .(female=sum(is_male==FALSE)), keyby = state]
  
  avg_weight = data_total[source_year %between% c(1970,2010), .(avg_weight_pounds=mean(weight_pounds,na.rm = TRUE)), keyby = state]
  avg_weight[, avg_weight_kgs := avg_weight_pounds / conv_factor_pounds_to_kgs, by=state]
  avg_weight_kgs = avg_weight[, c('state', 'avg_weight_kgs'), with=FALSE]
  </code></pre>
  
  <p>But I'm stuck on the replacement of race ids for race texts</p>
  
  <p>I have tried with:</p>
  
  <pre><code>data_total$test &lt;- match(race$race,data_total$child_race)
  </code></pre>
  
  <pre><code>data_total$test &lt;- race$race[match(race$race,data_total$child_race)]
  </code></pre>
  
  <pre><code>r70 = data_total[source_year %between% c(1970,1979), .(r70 = length(.N)), keyby = .(state,child_race)]
  </code></pre>
  
  <pre><code>r70$r70 &lt;- race$race[match(r70$r70,race$id_race)]
  </code></pre>
  
  <pre><code>r70[race, r70 := race, on = c(r70 = "race")]
  </code></pre>
  
  <p>I expect the output to be:</p>
  
  <pre><code>state  r70
  AK     "japanese"
  AL     "white"
  AR     "black"
  .      .
  .      .
  .      .
  </code></pre>