I have 2 dataframes like this
df1
date item
02/01/2017 A
09/01/2017 B
14/01/2017 C
df2
date1 date2 item prm
01/01/2017 03/01/2017 A YES
08/01/2017 10/01/2017 B YES
15/01/2017 17/01/2017 C YES
Purpose
The prm variable is a constant variable, it has the just 1 value.
I'd like to add the variable prm in my df1 with this condition
df1$date is between df2$date1 and df2$date2 and df1$item=df2$item
But, if the condition don't match, then I need that prm gets the value "NO"
library(data.table) ; setDT(df1)[setDT(df2), on = .(item, date >= date1, date <= date2), prm := i.prm](assuming the date formats are correct)