I have a main data.table which has 364 rows and the 3 columns:
Date        Weekday     Weight
2012-01-01  Monday      100
2013-01-02  Tuesday     200
...
and a help data.table with 7 rows 2 columns:
Weekday   Coefficient
Monday    0.91
Tuesday   0.84
Wednesday 0.99
...
Now i would like to create a 4th column in the main data.table with the "weight/Coefficient" based on the Weekday.
Weight_divided <- main[, Weight * help[Weekday==main$Weekday]$Coefficient]
The result is the following:
Date        Weekday     Weight   Weight_divided
2012-01-01  Monday      100      91
2013-01-02  Tuesday     200      168
2012-01-03  Wednesday   300      297
2012-01-04  Thursday    400      256
2012-01-05  Friday      500      399
2012-01-06  Saturday    600      410
2012-01-07  Sunday      700      680
2012-01-08  Monday      300      NA     <--
2012-01-09  Tuesday     600      NA     <--
...
I guess the issue is that the length of both data.tables is different. Is there a way how to reference in the main data.table operation that this works with a shorter data.table?
 
    