I want to calculate the distance between coordinates (I have them in WGS84 and RD, doesn't matter which one you use). I have a column HEX_Tag_ID
with coordinates on different dates Datum
. My final output must be the euclidean-distance between the coordinates of each HEX_Tag_ID
per the given Date Datum
. Which means the output will have a column with the ID numbers, Dates and to add on that the columns Lengte_(cm)
, Geslacht
and Sloot
.
So for example: ID number with 3D6.15341BF512 travelled 0 meter on 2022-04-21(start date is always 0 meters), 10 meters on 2022-05-23 (distance between the start date and first date), etc.
There must be a simple solution for my question, but I am unable to solve this. How should I approach this?
structure(list(Datum_Tijd = structure(c(1654599940, 1653640149,
1653901765, 1654245381, 1654586176, 1653025946, 1653631734, 1653026906,
1653302935, 1653023250, 1654238061, 1653032624, 1654245293, 1654581147,
1653901687, 1653033025, 1653632179, 1653303295, 1654238248, 1653893632,
1654587124, 1654844943, 1654586291, 1654235481, 1654237268, 1653901422,
1654580969, 1653639860, 1653638587, 1654243414, 1653900236, 1653286536,
1653630510, 1653631222, 1654586182, 1653023955, 1655099520, 1654235294,
1654584672, 1653300704, 1653630658, 1653033025, 1654581063, 1654236753,
1655101055, 1653301844, 1653025058, 1653892075, 1654244816, 1653032338,
1654845399, 1653026007, 1654842827, 1654235008, 1655099217, 1654584305,
1654244048, 1654580038, 1653286599, 1653638813, 1653292705, 1654600259,
1654586176, 1653025977, 1654844943, 1653892729, 1653901102, 1653631309,
1653300852, 1654842919, 1654585758, 1653630307, 1653031974, 1653639528,
1653901569, 1653630713, 1654236641, 1653025310, 1654585645, 1653301970,
1654236526, 1653892176, 1653301970, 1653630307, 1654843996, 1654585479,
1653026906, 1654586432, 1654237699, 1653893062, 1653303309, 1653026990,
1653631709, 1654600151, 1655123100, 1653300857, 1655101751, 1653639666,
1654244963, 1653639743, 1653901791, 1654245420, 1655101326, 1654845521,
1653632032, 1653893478, 1654238048, 1653302358, 1653027080, 1654238053,
1653893460, 1653631928, 1655103098, 1654838433, 1655109536, 1654579930,
1653891610, 1653023256, 1653301384, 1653301069, 1654585048, 1654235912,
1654845726, 1653638389, 1653286087, 1654579725, 1653900204, 1653900967,
1653287064, 1653639241, 1655111038, 1654839303, 1653301359, 1653023103,
1653022257, 1654585645, 1654844287, 1653023789, 1654236992, 1654237269,
1653631090, 1653025947, 1653023792, 1653301006, 1655100212, 1654584948,
1653629670, 1654235809, 1654585387, 1654838820, 1653286385, 1653900459,
1654243915, 1654594795, 1653629089, 1653890934, 1653300279, 1655118390,
1653032025, 1654235007, 1655100030, 1654584868, 1654237883, 1654586799,
1653904978, 1653290733, 1655114189, 1654599824, 1654236016, 1654843618,
1653891825, 1654585307, 1654236207, 1653301534, 1655100739, 1653629934,
1653286092, 1654838117, 1654243157, 1653900023, 1655109075, 1653030923,
1654237467, 1653026216, 1653302633, 1654586302, 1653631495, 1653031865,
1654244428, 1653286665, 1654580433, 1653638972, 1653900853, 1654580154,
1654838661, 1655110042, 1653910340, 1655118041, 1654600083, 1653628861
), tzone = "", class = c("POSIXct", "POSIXt")), Datum = structure(c(19150,
19139, 19142, 19146, 19150, 19132, 19139, 19132, 19135, 19132,
19146, 19132, 19146, 19150, 19142, 19132, 19139, 19135, 19146,
19142, 19150, 19153, 19150, 19146, 19146, 19142, 19150, 19139,
19139, 19146, 19142, 19135, 19139, 19139, 19150, 19132, 19156,
19146, 19150, 19135, 19139, 19132, 19150, 19146, 19156, 19135,
19132, 19142, 19146, 19132, 19153, 19132, 19153, 19146, 19156,
19150, 19146, 19150, 19135, 19139, 19135, 19150, 19150, 19132,
19153, 19142, 19142, 19139, 19135, 19153, 19150, 19139, 19132,
19139, 19142, 19139, 19146, 19132, 19150, 19135, 19146, 19142,
19135, 19139, 19153, 19150, 19132, 19150, 19146, 19142, 19135,
19132, 19139, 19150, 19156, 19135, 19156, 19139, 19146, 19139,
19142, 19146, 19156, 19153, 19139, 19142, 19146, 19135, 19132,
19146, 19142, 19139, 19156, 19153, 19156, 19150, 19142, 19132,
19135, 19135, 19150, 19146, 19153, 19139, 19135, 19150, 19142,
19142, 19135, 19139, 19156, 19153, 19135, 19132, 19132, 19150,
19153, 19132, 19146, 19146, 19139, 19132, 19132, 19135, 19156,
19150, 19139, 19146, 19150, 19153, 19135, 19142, 19146, 19150,
19139, 19142, 19135, 19156, 19132, 19146, 19156, 19150, 19146,
19150, 19142, 19135, 19156, 19150, 19146, 19153, 19142, 19150,
19146, 19135, 19156, 19139, 19135, 19153, 19146, 19142, 19156,
19132, 19146, 19132, 19135, 19150, 19139, 19132, 19146, 19135,
19150, 19139, 19142, 19150, 19153, 19156, 19142, 19156, 19150,
19139), class = "Date"), Tijd = c("13:05:40", "10:29:09", "11:09:25",
"10:36:21", "09:16:16", "07:52:26", "08:08:54", "08:08:26", "12:48:55",
"07:07:30", "08:34:21", "09:43:44", "10:34:53", "07:52:27", "11:08:07",
"09:50:25", "08:16:19", "12:54:55", "08:37:28", "08:53:52", "09:32:04",
"09:09:03", "09:18:11", "07:51:21", "08:21:08", "11:03:42", "07:49:29",
"10:24:20", "10:03:07", "10:03:34", "10:43:56", "08:15:36", "07:48:30",
"08:00:22", "09:16:22", "07:19:15", "07:52:00", "07:48:14", "08:51:12",
"12:11:44", "07:50:58", "09:50:25", "07:51:03", "08:12:33", "08:17:35",
"12:30:44", "07:37:38", "08:27:55", "10:26:56", "09:38:58", "09:16:39",
"07:53:27", "08:33:47", "07:43:28", "07:46:57", "08:45:05", "10:14:08",
"07:33:58", "08:16:39", "10:06:53", "09:58:25", "13:10:59", "09:16:16",
"07:52:57", "09:09:03", "08:38:49", "10:58:22", "08:01:49", "12:14:12",
"08:35:19", "09:09:18", "07:45:07", "09:32:54", "10:18:48", "11:06:09",
"07:51:53", "08:10:41", "07:41:50", "09:07:25", "12:32:50", "08:08:46",
"08:29:36", "12:32:50", "07:45:07", "08:53:16", "09:04:39", "08:08:26",
"09:20:32", "08:28:19", "08:44:22", "12:55:09", "08:09:50", "08:08:29",
"13:09:11", "14:25:00", "12:14:17", "08:29:11", "10:21:06", "10:29:23",
"10:22:23", "11:09:51", "10:37:00", "08:22:06", "09:18:41", "08:13:52",
"08:51:18", "08:34:08", "12:39:18", "08:11:20", "08:34:13", "08:51:00",
"08:12:08", "08:51:38", "07:20:33", "10:38:56", "07:32:10", "08:20:10",
"07:07:36", "12:23:04", "12:17:49", "08:57:28", "07:58:32", "09:22:06",
"09:59:49", "08:08:07", "07:28:45", "10:43:24", "10:56:07", "08:24:24",
"10:14:01", "11:03:58", "07:35:03", "12:22:39", "07:05:03", "06:50:57",
"09:07:25", "08:58:07", "07:16:29", "08:16:32", "08:21:09", "07:58:10",
"07:52:27", "07:16:32", "12:16:46", "08:03:32", "08:55:48", "07:34:30",
"07:56:49", "09:03:07", "07:27:00", "08:13:05", "10:47:39", "10:11:55",
"11:39:55", "07:24:49", "08:08:54", "12:04:39", "13:06:30", "09:33:45",
"07:43:27", "08:00:30", "08:54:28", "08:31:23", "09:26:39", "12:02:58",
"09:25:33", "11:56:29", "13:03:44", "08:00:16", "08:46:58", "08:23:45",
"09:01:47", "08:03:27", "12:25:34", "08:12:19", "07:38:54", "08:08:12",
"07:15:17", "09:59:17", "10:40:23", "10:31:15", "09:15:23", "08:24:27",
"07:56:56", "12:43:53", "09:18:22", "08:04:55", "09:31:05", "10:20:28",
"08:17:45", "07:40:33", "10:09:32", "10:54:13", "07:35:54", "07:24:21",
"10:47:22", "13:32:20", "13:00:41", "13:08:03", "07:21:01"),
Reader_ID = c("A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "Lite", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0", "A0",
"A0", "A0"), HEX_Tag_ID = c("3D6.15343A67C9", "3D6.15343A6824",
"3D6.15343A6824", "3D6.15343A6824", "3D6.15343A6829", "3D6.15343A6829",
"3D6.15343A6847", "3D6.15343A6847", "3D6.15343A6847", "3D6.15343A6848",
"3D6.15343A6848", "3D6.15343A688B", "3D6.15343A6AFB", "3D6.15343A6AFB",
"3D6.15343A6AFB", "3D6.15343A6AFB", "3D6.15343A6E01", "3D6.15343A6E01",
"3D6.15343A6E01", "3D6.15343A6E01", "3D6.15343A6E01", "3D6.15343A6E12",
"3D6.15343A6E12", "3D6.15343A6E56", "3D6.15343A6F23", "3D6.15343A71A8",
"3D6.15343A71A8", "3D6.15343A71B0", "3D6.15343A71B6", "3D6.15343A71B6",
"3D6.15343A71B6", "3D6.15343A71B6", "3D6.15343A71BF", "3D6.15343A71C3",
"3D6.15343A71C3", "3D6.15343A71D0", "3D6.15343A71E0", "3D6.15343A71E0",
"3D6.15343A71E0", "3D6.15343A71E0", "3D6.15343A7548", "3D6.15343A757C",
"3D6.15343A757C", "3D6.15343A75A6", "3D6.15343A75A6", "3D6.15343A75BB",
"3D6.15343A75BB", "3D6.15343A75BB", "3D6.15343A766B", "3D6.15343A766B",
"3D6.15343A7736", "3D6.15343A773B", "3D6.15343A773B", "3D6.15343A773B",
"3D6.15343A773B", "3D6.15343A773B", "3D6.15343A7CC8", "3D6.15343A7CC8",
"3D6.15343A7CC8", "3D6.15343A7CC8", "3D6.15343A7CF5", "3D6.15343A7CF5",
"3D6.15343A7DD8", "3D6.15343A7DD8", "3D6.15343A7DD8", "3D6.15343A7DD8",
"3D6.15343A8073", "3D6.15343A8317", "3D6.15343A831D", "3D6.15343A831D",
"3D6.15343A832E", "3D6.15343A832E", "3D6.15343A980B", "3D6.15343A99BC",
"3D6.15343A99BC", "3D6.15343A99D2", "3D6.15343A99FD", "3D6.15343A99FD",
"3D6.15343A99FD", "3D6.15343A99FD", "3D6.15343A9A1C", "3D6.15343A9A1C",
"3D6.15343A9A1C", "3D6.15343A9A1C", "3D6.15343A9A1C", "3D6.15343A9A1C",
"3D6.15343A9A1E", "3D6.15343A9A1E", "3D6.15343A9A1E", "3D6.15343A9A1E",
"3D6.15343A9A1E", "3D6.15343A9A4A", "3D6.15343A9A4A", "3D6.15343A9B79",
"3D6.15343A9B79", "3D6.15343A9BB0", "3D6.15343A9BF0", "3D6.15343A9BFC",
"3D6.15343A9BFC", "3D6.15343A9C1C", "3D6.15343A9C1C", "3D6.15343A9C1C",
"3D6.15343A9E7E", "3D6.15343A9E9D", "3D6.15343A9E9D", "3D6.15343A9E9D",
"3D6.15343A9E9D", "3D6.15343A9EF5", "3D6.15343A9F0C", "3D6.15343A9F0C",
"3D6.15343A9F0C", "3D6.15343A9F0C", "3D6.15343A9F0C", "3D6.15343A9F13",
"3D6.15343A9F13", "3D6.15343A9F13", "3D6.15343A9F18", "3D6.15343A9F18",
"3D6.15343A9F18", "3D6.15343AA124", "3D6.15343AA124", "3D6.15343AA124",
"3D6.15343AA124", "3D6.15343AA28F", "3D6.15343AA28F", "3D6.15343AA28F",
"3D6.15343AA28F", "3D6.15343AA34A", "3D6.15343AA34A", "3D6.15343AA34A",
"3D6.15343AA3B4", "3D6.15343AA3B4", "3D6.15343AA3C9", "3D6.15343AA3C9",
"3D6.15343AA3CD", "3D6.15343AA503", "3D6.15343AA503", "3D6.15343AA512",
"3D6.15343AA5EC", "3D6.15343AA601", "3D6.15343AA601", "3D6.15343AA601",
"3D6.15343AA680", "3D6.15343AA680", "3D6.15343AA680", "3D6.15343AA680",
"3D6.15343AA680", "3D6.15343AA680", "3D6.15343AA694", "3D6.15343AA6BB",
"3D6.15343AA6BB", "3D6.15343AA6BB", "3D6.15343AA6BB", "3D6.15343AA6CD",
"3D6.15343AA6CD", "3D6.15343AA6CD", "3D6.15343AA6CD", "3D6.15343AA6CD",
"3D6.15343AA6D0", "3D6.15343AA722", "3D6.15343AA72F", "3D6.15343AA72F",
"3D6.15343AA768", "3D6.15343AA768", "3D6.15343AA8D5", "3D6.15343AA8D5",
"3D6.15343AA8D5", "3D6.15343AA8D5", "3D6.15343AA8E6", "3D6.15343AA8E6",
"3D6.15343AA9A2", "3D6.15343AA9A2", "3D6.15343AA9A2", "3D6.15343AA9A2",
"3D6.15343AA9A2", "3D6.15343AA9A2", "3D6.15343AA9F9", "3D6.15343AA9F9",
"3D6.15343AA9F9", "3D6.15343AA9F9", "3D6.15343AA9F9", "3D6.15343AA9F9",
"3D6.15343AAA05", "3D6.15343AAA05", "3D6.15343AAA05", "3D6.15343AAA05",
"3D6.15343AAA16", "3D6.15343AAB0D", "3D6.15343AAB0D", "3D6.15343AAB0D",
"3D6.15343AAB0D", "3D6.15343AAB0D", "3D6.15343AAB0D", "3D6.15343AB519",
"3D6.15343AB519", "3D6.15343AB519", "3D6.15343AD0ED", "3D6.15343AD0ED",
"3D6.15343AD0ED", "3D6.15343AD0ED"), Longitude = c("4.7108",
"4.708930", "4.708940", "4.70892", "4.71132", "4.711330",
"4.711250", "4.711250", "4.711290", "4.711500", "4.71125",
"4.709030", "4.70899", "4.70896", "4.709010", "4.708950",
"4.711190", "4.711250", "4.71121", "4.711200", "4.71124",
"4.711310", "4.71131", "4.71153", "4.71134", "4.709010",
"4.70898", "4.709050", "4.709090", "4.70911", "4.709130",
"4.709070", "4.711360", "4.711330", "4.71132", "4.711450",
"4.711500", "4.71158", "4.71149", "4.711490", "4.711360",
"4.708950", "4.709", "4.71139", "4.711400", "4.711430", "4.711410",
"4.711400", "4.709", "4.709010", "4.711290", "4.711330",
"4.711540", "4.71158", "4.711570", "4.71163", "4.70908",
"4.70907", "4.709070", "4.709080", "4.711480", "4.71175",
"4.71132", "4.711330", "4.711310", "4.711310", "4.709020",
"4.711310", "4.711490", "4.711550", "4.71138", "4.711400",
"4.709020", "4.709050", "4.709020", "4.711360", "4.7114",
"4.711400", "4.71139", "4.711420", "4.71141", "4.711390",
"4.711420", "4.711400", "4.711440", "4.71141", "4.711250",
"4.71131", "4.71127", "4.711280", "4.711250", "4.711250",
"4.711250", "4.71142", "4.7114554", "4.711490", "4.711380",
"4.709040", "4.70901", "4.709020", "4.708940", "4.70892",
"4.711520", "4.711270", "4.711220", "4.711230", "4.71125",
"4.711370", "4.711240", "4.71125", "4.711230", "4.711240",
"4.711180", "4.709050", "4.709080", "4.70908", "4.711480",
"4.711500", "4.711480", "4.711490", "4.71146", "4.71148",
"4.711240", "4.709100", "4.709110", "4.70909", "4.709130",
"4.709030", "4.709020", "4.709050", "4.708970", "4.708980",
"4.711480", "4.711510", "4.711610", "4.71139", "4.711400",
"4.711460", "4.71136", "4.71134", "4.711340", "4.711330",
"4.711460", "4.711490", "4.711460", "4.71146", "4.711460",
"4.71148", "4.71142", "4.709020", "4.709090", "4.709110",
"4.70909", "4.71104", "4.711520", "4.711600", "4.711580",
"4.711520", "4.709020", "4.71158", "4.711460", "4.71147",
"4.71126", "4.71129", "4.710210", "4.710230", "4.710420",
"4.71035", "4.71145", "4.711490", "4.711440", "4.71142",
"4.71144", "4.711460", "4.711370", "4.711430", "4.709110",
"4.709080", "4.70907", "4.709160", "4.709120", "4.709070",
"4.71132", "4.711310", "4.711330", "4.71131", "4.711280",
"4.709030", "4.70902", "4.709060", "4.70902", "4.709070",
"4.709040", "4.70906", "4.709040", "4.709040", "4.711610",
"4.711290", "4.71127", "4.711570"), Latitude = c("51.935299",
"51.931229", "51.931381", "51.93137", "51.93203", "51.932041",
"51.931271", "51.931271", "51.931332", "51.934292", "51.931122",
"51.931839", "51.93148", "51.931492", "51.931499", "51.931358",
"51.930771", "51.930820", "51.93082", "51.930790", "51.930759",
"51.931862", "51.931889", "51.93457", "51.932171", "51.931839",
"51.93169", "51.931568", "51.932980", "51.933319", "51.933262",
"51.932880", "51.932598", "51.932030", "51.93203", "51.933842",
"51.934910", "51.93486", "51.934639", "51.934471", "51.932461",
"51.931358", "51.931591", "51.932892", "51.933159", "51.933208",
"51.933281", "51.933170", "51.93206", "51.932121", "51.931259",
"51.932041", "51.935349", "51.935268", "51.935341", "51.935299",
"51.932819", "51.93285", "51.932880", "51.932739", "51.935539",
"51.93544", "51.93203", "51.932041", "51.931862", "51.932041",
"51.932240", "51.931881", "51.934189", "51.935211", "51.93288",
"51.933022", "51.932480", "51.931931", "51.931599", "51.932461",
"51.933029", "51.933022", "51.933029", "51.933071", "51.933159",
"51.933041", "51.933071", "51.933022", "51.933418", "51.933289",
"51.931271", "51.931721", "51.931599", "51.931580", "51.930820",
"51.931271", "51.931271", "51.935379", "51.9353700", "51.934189",
"51.932621", "51.931808", "51.931938", "51.931690", "51.931381",
"51.931381", "51.932899", "51.931091", "51.930939", "51.931122",
"51.931122", "51.932369", "51.931110", "51.931122", "51.931122",
"51.931099", "51.931099", "51.933010", "51.932991", "51.93298",
"51.933868", "51.934292", "51.933899", "51.934040", "51.934021",
"51.934021", "51.930752", "51.933231", "51.933369", "51.933239",
"51.933262", "51.932362", "51.932339", "51.932331", "51.931870",
"51.931839", "51.933899", "51.934410", "51.935211", "51.933029",
"51.932999", "51.933990", "51.932449", "51.932171", "51.932171",
"51.932041", "51.933990", "51.934040", "51.934139", "51.934181",
"51.934010", "51.934158", "51.93343", "51.932499", "51.932999",
"51.933029", "51.932968", "51.93544", "51.934940", "51.934978",
"51.935242", "51.935551", "51.932480", "51.935268", "51.934280",
"51.934349", "51.931301", "51.931271", "51.935379", "51.935390",
"51.935360", "51.935242", "51.933868", "51.933990", "51.933609",
"51.933578", "51.933609", "51.933620", "51.933640", "51.933620",
"51.933369", "51.933479", "51.933552", "51.933510", "51.933491",
"51.933350", "51.932018", "51.931900", "51.931950", "51.931889",
"51.931549", "51.932610", "51.932461", "51.932739", "51.932331",
"51.932610", "51.932499", "51.93272", "51.932758", "51.932770",
"51.935429", "51.935520", "51.93536", "51.935200"), x = c(108483.518,
108350.695, 108351.54, 108350.153, 108515.896, 108516.595,
108510.297, 108510.297, 108513.111, 108530.615, 108510.142,
108358.205, 108355.082, 108353.031, 108356.477, 108352.204,
108505.653, 108509.83, 108507.079, 108506.36, 108509.079,
108515.035, 108515.062, 108532.966, 108517.417, 108356.83,
108354.612, 108359.299, 108363.516, 108365.243, 108366.56,
108362.037, 108519.235, 108516.584, 108515.896, 108526.711,
108531.254, 108536.704, 108530.286, 108530.112, 108519.093,
108352.204, 108355.885, 108521.602, 108522.566, 108524.68,
108523.38, 108522.577, 108356.371, 108357.123, 108513.035,
108516.595, 108534.459, 108537.126, 108536.514, 108540.597,
108362.661, 108362.006, 108362.037, 108362.578, 108530.529,
108548.995, 108515.896, 108516.595, 108515.035, 108515.22,
108357.934, 108515.054, 108529.821, 108535.004, 108520.902,
108522.424, 108358.183, 108359.676, 108357.268, 108519.093,
108522.431, 108522.424, 108521.744, 108523.85, 108523.254,
108521.756, 108523.85, 108522.424, 108525.585, 108523.388,
108510.297, 108514.889, 108512.011, 108512.68, 108509.83,
108510.297, 108510.297, 108526.238, 108528.663, 108529.821,
108520.634, 108358.861, 108356.933, 108357.363, 108351.54,
108350.165, 108530.55, 108511.486, 108507.89, 108508.767,
108510.142, 108519.685, 108509.442, 108510.142, 108508.767,
108509.431, 108505.304, 108360.796, 108362.84, 108362.828,
108528.801, 108530.615, 108528.833, 108529.667, 108527.584,
108528.959, 108509.072, 108364.464, 108365.295, 108363.785,
108366.56, 108358.748, 108358.037, 108360.091, 108354.111,
108354.767, 108528.833, 108531.425, 108539.13, 108521.744,
108522.4, 108527.552, 108519.081, 108517.417, 108517.417,
108516.595, 108527.552, 108529.667, 108527.706, 108527.749,
108527.573, 108529.101, 108524.222, 108358.203, 108363.536,
108364.942, 108363.504, 108500.169, 108532.661, 108538.202,
108537.099, 108533.293, 108358.183, 108537.126, 108527.852,
108528.611, 108511.015, 108513.048, 108443.027, 108444.414,
108457.449, 108452.513, 108526.738, 108529.615, 108525.782,
108524.375, 108525.782, 108527.169, 108521, 108525.106, 108365.295,
108363.346, 108362.734, 108368.88, 108366.11, 108362.525,
108515.884, 108515.074, 108516.501, 108515.062, 108512.647,
108359.006, 108358.163, 108361.203, 108358.028, 108361.757,
108359.578, 108361.183, 108359.847, 108359.859, 108539.356,
108517.444, 108515.903, 108536.368), y = c(438753.654, 438302.052,
438318.956, 438317.745, 438389.635, 438390.852, 438305.238,
438305.238, 438311.999, 438641.174, 438288.662, 438369.853,
438329.938, 438331.293, 438332.039, 438316.391, 438249.65,
438255.063, 438255.089, 438251.758, 438248.283, 438370.951,
438373.954, 438672.084, 438405.309, 438369.865, 438353.308,
438339.69, 438496.754, 438534.456, 438528.102, 438485.641,
438452.801, 438389.628, 438389.635, 438591.142, 438709.929,
438704.315, 438679.786, 438661.095, 438437.559, 438316.391,
438342.281, 438485.49, 438515.189, 438520.621, 438528.755,
438516.412, 438394.459, 438401.239, 438303.878, 438390.852,
438758.744, 438749.707, 438757.834, 438753.123, 438478.849,
438482.304, 438485.641, 438469.948, 438779.92, 438768.733,
438389.635, 438390.852, 438370.951, 438390.865, 438414.471,
438373.064, 438629.722, 438743.384, 438484.162, 438499.947,
438441.172, 438380.075, 438343.158, 438437.559, 438500.726,
438499.947, 438500.732, 438505.385, 438515.182, 438502.067,
438505.385, 438499.947, 438543.978, 438529.645, 438305.238,
438355.264, 438341.717, 438339.596, 438255.063, 438305.238,
438305.238, 438762.158, 438761.134, 438629.722, 438455.347,
438366.397, 438380.879, 438353.282, 438318.956, 438318.969,
438486.186, 438285.2, 438268.322, 438288.674, 438288.662,
438427.318, 438287.333, 438288.662, 438288.674, 438286.109,
438286.148, 438500.117, 438497.984, 438496.76, 438594.016,
438641.174, 438597.465, 438613.145, 438611.05, 438611.038,
438247.504, 438524.672, 438540.019, 438525.568, 438528.102,
438428.038, 438425.486, 438424.576, 438373.34, 438369.885,
438597.465, 438654.296, 438743.346, 438500.732, 438497.388,
438607.602, 438436.224, 438405.309, 438405.309, 438390.852,
438607.602, 438613.145, 438624.178, 438628.851, 438609.827,
438626.279, 438545.325, 438443.286, 438498.868, 438502.192,
438495.419, 438769.187, 438713.254, 438717.43, 438746.814,
438781.23, 438441.172, 438749.707, 438639.865, 438647.535,
438308.57, 438305.213, 438762.932, 438764.143, 438760.684,
438747.601, 438594.035, 438607.582, 438565.227, 438561.791,
438565.227, 438566.438, 438568.72, 438566.457, 438540.019,
438552.276, 438560.404, 438555.673, 438553.585, 438537.93,
438388.3, 438375.178, 438380.728, 438373.954, 438336.148,
438455.629, 438439.058, 438469.961, 438424.595, 438455.603,
438443.273, 438467.847, 438472.088, 438473.423, 438767.599,
438777.928, 438760.14, 438742.148), `Lengte_(cm)` = c(10.4,
9.8, 9.8, 9.8, 8.3, 8.3, 9.3, 9.3, 9.3, 11, 11, 10.5, 10,
10, 10, 10, 10.1, 10.1, 10.1, 10.1, 10.1, 8.7, 8.7, 6.6,
8.1, 10.8, 10.8, 9.8, 12, 12, 12, 12, 9.7, 11.2, 11.2, 7.8,
7.9, 7.9, 7.9, 7.9, 10.2, 12.9, 12.9, 9.3, 9.3, 10, 10, 10,
10.4, 10.4, 8.6, 8, 8, 8, 8, 8, 11, 11, 11, 11, 10.6, 10.6,
10.5, 10.5, 10.5, 10.5, 11.9, 10, 7.2, 7.2, 9.6, 9.6, 11.5,
11, 11, 7.9, 9.3, 9.3, 9.3, 9.3, 8.9, 8.9, 8.9, 8.9, 8.9,
8.9, 9.5, 9.5, 9.5, 9.5, 9.5, 9.1, 9.1, 8.7, 8.7, 9.8, 8.9,
11.5, 11.5, 10.9, 10.9, 10.9, 8.8, 8.6, 8.6, 8.6, 8.6, 8,
9.3, 9.3, 9.3, 9.3, 9.3, 8.5, 8.5, 8.5, 9.9, 9.9, 9.9, 9,
9, 9, 9, 9.5, 9.5, 9.5, 9.5, 12.1, 12.1, 12.1, 7.7, 7.7,
10.8, 10.8, 11, 7.5, 7.5, 7.4, 8.2, 9.9, 9.9, 9.9, 11.2,
11.2, 11.2, 11.2, 11.2, 11.2, 11.5, 10, 10, 10, 10, 9.4,
9.4, 9.4, 9.4, 9.4, 10.8, 10, 9.7, 9.7, 9.8, 9.8, 11.2, 11.2,
11.2, 11.2, 7.2, 7.2, 11, 11, 11, 11, 11, 11, 11.8, 11.8,
11.8, 11.8, 11.8, 11.8, 8.6, 8.6, 8.6, 8.6, 9.4, 9.7, 9.7,
9.7, 9.7, 9.7, 9.7, 10.7, 10.7, 10.7, 9, 9, 9, 9), Geslacht = c("man",
"vrouw", "vrouw", "vrouw", "man", "man", "vrouw", "vrouw",
"vrouw", "man", "man", "man", "man", "man", "man", "man",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "man", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "man", "man", "vrouw", "man",
"man", "man", "man", "vrouw", "man", "man", "man", "man",
"vrouw", "vrouw", "vrouw", "man", "man", "vrouw", "man",
"man", "man", "man", "man", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw",
"man", "vrouw", "vrouw", "man", "man", "man", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "man", "man",
"man", "man", "man", "man", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "man", "man", "man", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "man",
"man", "man", "man", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw",
"man", "man", "vrouw", "man", "man", "man", "man", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "man", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "man", "man", "vrouw",
"vrouw", "man", "man", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "man", "man", "man", "man", "man", "man", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw",
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "man",
"man", "man", "man"), Sloot = c("Noord", "22", "22", "22",
"26", "26", "26", "26", "26", "26", "26", "22", "22", "22",
"22", "22", "26", "26", "26", "26", "26", "26", "26", "26",
"26", "22", "22", "22", "22", "22", "22", "22", "26", "26",
"26", "26", "26", "26", "26", "26", "26", "22", "22", "26",
"26", "26", "26", "26", "22", "22", "26", "26", "26", "26",
"26", "26", "22", "22", "22", "22", "Noord", "Noord", "26",
"26", "26", "26", "22", "26", "26", "26", "26", "26", "22",
"22", "22", "26", "26", "26", "26", "26", "26", "26", "26",
"26", "26", "26", "26", "26", "26", "26", "26", "26", "26",
"Noord", "Noord", "26", "26", "22", "22", "22", "22", "22",
"26", "26", "26", "26", "26", "26", "26", "26", "26", "26",
"26", "22", "22", "22", "26", "26", "26", "26", "26", "26",
"26", "22", "22", "22", "22", "22", "22", "22", "22", "22",
"26", "26", "26", "26", "26", "26", "26", "26", "26", "26",
"26", "26", "26", "26", "26", "26", "26", "22", "22", "22",
"22", "Noord", "26", "26", "26", "Noord", "22", "26", "26",
"26", "26", "26", "Noord", "Noord", "Noord", "Noord", "26",
"26", "26", "26", "26", "26", "26", "26", "22", "22", "22",
"22", "22", "22", "26", "26", "26", "26", "26", "22", "22",
"22", "22", "22", "22", "22", "22", "22", "Noord", "Noord",
"Noord", "26"), Lengte_8e_lichting = c(NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, 8.3, NA, NA, NA, NA, NA, NA, NA, 9.8, NA, NA, NA, NA,
NA, NA, NA, NA, NA, 8.9, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, 10.8, NA, 10.5, NA, NA, NA, NA, NA, 10.5, NA, NA, NA,
NA, NA, NA, NA, NA, NA, 10.1, NA, 10.5, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 9.8, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 11.7, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 10.2, NA, NA, 11, NA,
NA, NA, NA, NA, 11.6, NA, NA, NA, NA, NA, NA, NA, 11.3, NA,
NA, NA, NA, NA, 11.4, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, 12.3, NA, 9.2, NA, NA)), row.names = c(NA,
-200L), class = c("tbl_df", "tbl", "data.frame"))
CodePudding user response:
Assuming that the data is assigned to df
.
The key is to use the lag
function.
library(dplyr); library(tidyr)
df_dist <- df %>%
group_by(HEX_Tag_ID) %>%
arrange(Datum) %>% # Sort the dataframe by Date
mutate(
distance = sqrt((x - lag(x))^2 (y - lag(y))^2), # The "lag" function shifts a vector
date_start = lag(Datum),
date_end = Datum) %>%
drop_na(distance) %>% # Removes rows with distance == NA, because the lag function return an NA for the first element
select(HEX_Tag_ID, date_start, date_end, , distance, `Lengte_(cm)`, Geslacht, Sloot)