Actually, for each animal I need to identify the accumulated distance travelled (column "DistK-[cm]") at the last test date at the time that is closest to 6 AM. These values are shown in the "Dist 6 AM" column (and summarized in the 6 AM distance data set (I´m not sure that I need this though)).
Then I need to adjust it for baseline, meaning, I need to subtract the accumulated distance travelled until 30 min after dosing. For this I would use the "Time since dosing" column, identify the rows where the value in this column equals 0.5 hours (which is what I did with "get rows where" ) which provides me a list of values (one value per animal) [1218, 2999, 5368, 2187, 2242, 3457, 3171, 5008, 4022, 3822, 5429, 3060, 2972, 3162, 5659, 2280].
So in this example animal 1 has travelled 43343 cm at 5.58 AM and then I need to subtract the value at 30 min after dosing (in this case the first value in the list: 1218 cm). How do I do this in a robust manner? With a loop that iterates through the list?