You could achieve your desired result via dplyr::distinct
and dplyr::left_join
like so:
library(dplyr)
origin5 %>%
left_join(distinct(origin5, Kanton, long, lat), by = c("Kanton_origin" = "Kanton"), suffix = c("", "_origin"))
#> Numéro Kanton long lat Kanton_origin long_origin lat_origin
#> 1 PGV02.064 FR 571183.5 174640.0 VD 539884.5 159601
#> 2 PGV02.064 NE 548363.0 206421.0 VD 539884.5 159601
#> 3 PGV02.064 VD 539884.5 159601.0 VD 539884.5 159601
#> 4 PGV02.064 VS 614169.5 122992.5 VD 539884.5 159601
#> 5 PGV02.026 GE 499192.0 122622.5 VD 539884.5 159601
#> 6 PGV01.079 VD 539884.5 159601.0 VD 539884.5 159601
#> 7 PGV02.003 VD 539884.5 159601.0 VD 539884.5 159601
#> 8 PGV01.108 VD 539884.5 159601.0 VD 539884.5 159601
#> 9 PGV02.036 BE 616990.0 187209.0 FR 571183.5 174640
#> 10 PGV03.026 FR 571183.5 174640.0 FR 571183.5 174640
#> 11 PGV02.036 TI 702684.0 120482.0 FR 571183.5 174640
#> 12 PGV02.036 VD 539884.5 159601.0 FR 571183.5 174640
#> 13 PGV03.034 BE 616990.0 187209.0 NE 548363.0 206421
#> 14 PGV03.034 GE 499192.0 122622.5 NE 548363.0 206421
#> 15 PGV03.034 NE 548363.0 206421.0 NE 548363.0 206421
Created on 2021-02-05 by the reprex package (v1.0.0)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…