I have this mapping table.
df <- data.frame(L = c(1, 2, 3, 4, 5, 6, 7, 8, 9),
fli.1 = c(0, 500, 1000, 2000, 3000, 5000, 10000, 20000, 50000),
fli.2 = c(0, 500, 1000, 2000, 3000, 5000, 10000, 20000, 50000),
fli.3 = c(0, 500, 1000, 2000, 3000, 5000, 10000, 20000, 50000),
fli.4 = c(0, 500, 1000, 2000, 3000, 5000, 10000, 20000, 50000),
fli.5 = c(0, 500, 1000, 2000, 3000, 5000, 10000, 20000, 50000))
I have another dataframe which is
d <- data.frame(quantity = c(300, 368, 568, 20, 1000, 37659, 45000, 2500, 4500, 78453, 1200, 1589), fli = c("fli.1", "fli.1", "fli.4", "fli.5", "fli.2", "fli.2", "fli.5", "fli.1", "fli.2", "fli.2", "fli.3", "fli.4"))
i need to create another vector in dataframe d such that it is taking values from dataframe df. vertically look for less than quantity and horizontally match fli.
for e.g. for 37659 it would be 20000 which is 8th row and from column fli.1
This is just an demonstration.
I need to apply it for huge dataset.
i tried creating a matrix but it takes time. i need something faster.