我们需要在lead
这里使用
library(dplyr)
df2 <- df1 %>%
mutate(across(c(long, lat), ~ lead(., default = last(.)),
.names = '{col}to}'))
在中base R
,我们可以做
df1[c('longto', 'latto')] <- df1[c(2:nrow(df1), nrow(df1)), c('long', 'lat)]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句