1

I want to add a row for every unique value of HEX_Tag_ID, with the following added data: "2022-04-21" in date_end, 0 in Afstand and 0 in Afstand_cum. The rest of the data can be copied that belongs to its respective HEX_Tag_ID. Is there a quick and easy way to add this data, preferebly with dplyr?

desired outcome (shows only example of 2 unique ID's):

enter image description here

dput(Afstand_cumulatief)

structure(list(HEX_Tag_ID = c("3D6.153413ECBC", "3D6.153413ECBC", 
"3D6.153413ECBC", "3D6.153413ECE0", "3D6.153413ECE0", "3D6.153413ECE0", 
"3D6.153413EF72", "3D6.153413EF72", "3D6.153413EF72", "3D6.153413EF72", 
"3D6.153413EF72", "3D6.153413EF72", "3D6.15341B9871", "3D6.15341B9871", 
"3D6.15341B9871", "3D6.15341B9871", "3D6.15341B9871", "3D6.15341B9B1D", 
"3D6.15341B9B1D", "3D6.15341B9B1D", "3D6.15341B9B36", "3D6.15341BA2E5", 
"3D6.15341BA2E5", "3D6.15341BA2E5", "3D6.15341BA3BA", "3D6.15341BA4AA", 
"3D6.15341BA4AA", "3D6.15341BA4AA", "3D6.15341BA4AA", "3D6.15341BAACC", 
"3D6.15341BAD53", "3D6.15341BADE3", "3D6.15341BADE3", "3D6.15341BAE18", 
"3D6.15341BAE4D", "3D6.15341BAE4D", "3D6.15341BAE4D", "3D6.15341BB40B", 
"3D6.15341BB40B", "3D6.15341BB40B", "3D6.15341BB40B", "3D6.15341BB40B", 
"3D6.15341BB40B", "3D6.15341BB40B", "3D6.15341BB46B", "3D6.15341BB46B", 
"3D6.15341BB46B", "3D6.15341BB46B", "3D6.15341BB664", "3D6.15341BB664"
), date_start = structure(c(19103, 19135, 19142, 19103, 19132, 
19139, 19103, 19135, 19142, 19150, 19150, 19156, 19103, 19132, 
19135, 19139, 19142, 19103, 19135, 19142, 19103, 19103, 19142, 
19150, 19103, 19103, 19132, 19135, 19139, 19103, 19103, 19103, 
19132, 19103, 19103, 19135, 19142, 19103, 19135, 19139, 19142, 
19146, 19150, 19153, 19103, 19132, 19135, 19139, 19103, 19132
), class = "Date"), date_end = structure(c(19135, 19142, 19156, 
19132, 19139, 19142, 19135, 19142, 19150, 19150, 19156, 19156, 
19132, 19135, 19139, 19142, 19146, 19135, 19142, 19150, 19153, 
19142, 19150, 19156, 19142, 19132, 19135, 19139, 19146, 19156, 
19132, 19132, 19135, 19135, 19135, 19142, 19150, 19135, 19139, 
19142, 19146, 19150, 19153, 19156, 19132, 19135, 19139, 19142, 
19132, 19135), class = "Date"), Afstand = c(6.00826097971526, 
13.1120984209164, 2.06308749207997, 36.5186697594105, 50.0661780546056, 
6.54055173511978, 28.0242276967593, 14.6123825914889, 15.9740913043467, 
27.4861005055185, 30.6066300006984, 11.5224248315983, 9.81078844947105, 
4.03639542165653, 0, 4.89547842402071, 20.6482174049022, 79.0931499246234, 
4.81421031945884, 5.5012364064859, 28.0091903667337, 4.68787851804202, 
41.8046854072709, 2.4581753395832, 9.06092738075898, 22.5215546754316, 
29.2195753733562, 0, 35.6625118156259, 78.8848357607789, 14.4020923826949, 
5.90781897150074, 27.2624870839374, 16.863907761852, 56.8054493600705, 
12.2574004177131, 12.5247678221842, 1.40345644748983, 2.52194884956613, 
4.12618431483991, 8.86078963750033, 4.87694351000967, 1.91751740541371, 
53.562964303717, 9.34577690726484, 10.1700273352522, 13.6429323827364, 
5.85758388758672, 115.059650833812, 18.3815822223942), `Lengte_(cm)` = c(9, 
9, 9, 10.5, 10.5, 10.5, 10.7, 10.7, 10.7, 10.7, 10.7, 10.7, 10.6, 
10.6, 10.6, 10.6, 10.6, 10.6, 10.6, 10.6, 9.9, 7.7, 7.7, 7.7, 
8.1, 8.2, 8.2, 8.2, 8.2, 9.1, 10.6, 9.3, 9.3, 11.2, 12.1, 12.1, 
12.1, 11.2, 11.2, 11.2, 11.2, 11.2, 11.2, 11.2, 10.5, 10.5, 10.5, 
10.5, 11.5, 11.5), Geslacht = c("man", "man", "man", "man", "man", 
"man", "man", "man", "man", "man", "man", "man", "man", "man", 
"man", "man", "man", "vrouw", "vrouw", "vrouw", "vrouw", "man", 
"man", "man", "vrouw", "man", "man", "man", "man", "man", "man", 
"vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "vrouw", "man", 
"man", "man", "man", "man", "man", "man", "vrouw", "vrouw", "vrouw", 
"vrouw", "vrouw", "vrouw"), Sloot = c("Noord", "Noord", "Noord", 
"22", "22", "22", "Noord", "Noord", "Noord", "Noord", "Noord", 
"Noord", "22", "22", "22", "22", "22", "Noord", "Noord", "Noord", 
"22", "Noord", "Noord", "Noord", "Noord", "22", "22", "22", "22", 
"22", "22", "22", "22", "Noord", "Noord", "Noord", "Noord", "22", 
"22", "22", "22", "22", "22", "22", "22", "22", "22", "22", "22", 
"22"), Lengteklasse = structure(c(4L, 4L, 4L, 5L, 5L, 5L, 5L, 
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 2L, 2L, 
2L, 3L, 3L, 3L, 3L, 3L, 4L, 5L, 4L, 4L, 6L, 7L, 7L, 7L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 6L, 6L), .Label = c("6", 
"7", "8", "9", "10", "11", "12", "13"), class = "factor"), Afstand_cum = c(6.00826097971526, 
19.1203594006317, 21.1834468927117, 36.5186697594105, 86.584847814016, 
93.1253995491358, 28.0242276967593, 42.6366102882482, 58.6107015925949, 
86.0968020981134, 116.703432098812, 128.22585693041, 9.81078844947105, 
13.8471838711276, 13.8471838711276, 18.7426622951483, 39.3908797000505, 
79.0931499246234, 83.9073602440823, 89.4085966505682, 28.0091903667337, 
4.68787851804202, 46.4925639253129, 48.9507392648961, 9.06092738075898, 
22.5215546754316, 51.7411300487877, 51.7411300487877, 87.4036418644136, 
78.8848357607789, 14.4020923826949, 5.90781897150074, 33.1703060554382, 
16.863907761852, 56.8054493600705, 69.0628497777836, 81.5876175999678, 
1.40345644748983, 3.92540529705596, 8.05158961189587, 16.9123792493962, 
21.7893227594059, 23.7068401648196, 77.2698044685365, 9.34577690726484, 
19.515804242517, 33.1587366252534, 39.0163205128401, 115.059650833812, 
133.441233056206)), class = c("grouped_df", "tbl_df", "tbl", 
"data.frame"), row.names = c(NA, -50L), groups = structure(list(
    HEX_Tag_ID = c("3D6.153413ECBC", "3D6.153413ECE0", "3D6.153413EF72", 
    "3D6.15341B9871", "3D6.15341B9B1D", "3D6.15341B9B36", "3D6.15341BA2E5", 
    "3D6.15341BA3BA", "3D6.15341BA4AA", "3D6.15341BAACC", "3D6.15341BAD53", 
    "3D6.15341BADE3", "3D6.15341BAE18", "3D6.15341BAE4D", "3D6.15341BB40B", 
    "3D6.15341BB46B", "3D6.15341BB664"), .rows = structure(list(
        1:3, 4:6, 7:12, 13:17, 18:20, 21L, 22:24, 25L, 26:29, 
        30L, 31L, 32:33, 34L, 35:37, 38:44, 45:48, 49:50), ptype = integer(0), class = c("vctrs_list_of", 
    "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -17L), .drop = TRUE))
Pepijn95
  • 321
  • 1
  • 6

0 Answers0