Hello,
I appreciate that the title might be confusing so I will try to explain more here.
So, consider the following data.table
:
sampleDT <- data.table(id = c(1,2,3,4,5),
dist = c(111.0200,124.0074,124.1337,128.0353,132.0303),
score = c(2985048,21641962,2627225,10382804,4338643)
)
I would like to subtract all the distances (column: dist
) with the next ones in the array and make a conditional check for the resulted value. Pseudocode below to demo the logic:
if(dist[1]-dist[2] == xval) then sampleDT[, point := "Keep"] else continue,
if(dist[1]-dist[3] == xval) then sampleDT[, point := "Keep"] else continue,
if(dist[1]-dist[4] == xval) then sampleDT[, point := "Keep"] else continue,
if(dist[1]-dist[5] == xval) then sampleDT[, point := "Keep"] else continue,
if(dist[2]-dist[3] == xval) then sampleDT[, point := "Keep"] else continue,
if(dist[2]-dist[4] == xval) then sampleDT[, point := "Keep"] else continue,
if(dist[2]-dist[5] == xval) then sampleDT[, point := "Keep"] else continue,
.
.
.
if(dist[4]-dist[5] == xval) then sampleDT[, point := "Keep"] else continue
Visual representation of the hops I want to be performed.
Is something like this feasible?