I have a situation where I have two data frames I would like to join. The table
params describes the param for a unit in terms time and angle ranges. The table data is longer and contains id, time and angle parameters.
I would like to join the param value from params when id match and time is in the range between valid_from and valid_to and ang is between angle_begin angle_end in the data table.
Below is an example of the tables.
params <- data.frame(id = 1:4
,valid_from = 1
,valid_to = c(10, 20, 30, 40)
,angle_begin = c(120, 90, 0, 50)
,angle_end = c(180, 170, 160, 150)
,param = c("A", "B", "C", "D"))
data <- data.frame(id = rep(1:4, each=100)
,time = rep(seq(from = 0.5, to = 50, by = 0.5), 4)
,ang = rep(runif(100, 0, 360), 4))