我希望我要问的内容非常简单,而我的谷歌foo也很差。
使用sf包中的st_intersects,我可以获得每个点及其相交点的表格。
我正在尝试按照以下示例将它们结合在一起。我缺少什么基本功能?我可以循环执行此操作,但效率似乎很低。
**Example:**
df <- data.frame(
Source = c(1,1,2,2,2,3),
Match = c(1,2,2,1,4,3),
stringsAsFactors = FALSE)
print(df)
Source Match
1 1
1 2
2 2
2 1
2 4
3 3
**Desired output:**
Source Match
1 1
1 2
1 4
3 3
因为匹配2在源1中,源2中的每个匹配都已移至源1。