It's not altogether clear how you want to "cut" the two data sets, if by lowest matching from
value, or complete match across a row.
Try the following:
library(data.table)
ft <- c("from", "to")
allVals <- unique(sort(unlist(c(df1[, ft], df2[, ft]))))
results <- data.table(from=head(allVals, -1), to=allVals[-1L])
results[,
c("Lith", "Weath") :=
lapply(list(
df1[from >= df1[["from"]] & to <= df1[["to"]], "Lith"],
df2[from >= df2[["from"]] & to <= df2[["to"]], "Weath"]
# alternatively, someting like:
# df1[which.max(from >= df1[["from"]]), "Lith"],
# df2[which.max(from >= df2[["from"]]), "Weath"]
), as.character)
, by=list(from, to)]
results
from to Lith Weath
1: 0.0 1.1 GRN HW
2: 1.1 1.2 GRN SW
3: 1.2 2.9 GDI SW
4: 2.9 5.0 GDI HW