2
I have a data frame x
, and in the column of the name V_de_Busca
, where the value is greater than 0, I need to search the column V_Encontrado
and locate the first value larger than the one searched by following the indexes.
Thus, for example, the value "12" would have to return "14" and not "15", because it is in a date earlier than the value "12" sought. Another example the value "17" would have to return the value of "20", or the value "10" would have to return "12".
x = data.frame(Índice = c(1,2,3,4,5,6,7,8,9,10),
Data = as.Date(c("2019-01-22", "2019-01-21", "2019-01-20", "2019-01-18", "2019-01-17", "2019-01-16", "2019-01-15", "2019-01-14", "2019-01-11", "2019-01-10")),
V_Encontrado = c(10,15,18,14,09,06,12,13,20,22),
V_de_Busca = c(0,0,0,12,0,10,0,17,07,0))
Perfect, thank you very much. Solved everything you needed.
– Thallys Geovany