How to assign a name to lat-long observations based on shortest distance

后端 未结 1 1638
粉色の甜心
粉色の甜心 2021-01-26 13:00

I have two dataframes: df1 contains observations with lat-lon coordinates; df2 has names with lat-lon coordinates. I want to create a new variable

1条回答
  •  星月不相逢
    2021-01-26 13:14

    Like this:

    df1$name <- df2$latlonloc[apply(mat, 1, which.min)]
    

    0 讨论(0)
提交回复
热议问题