Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
976 views
in Technique[技术] by (71.8m points)

dplyr - how to leave only one value (the most recent) from the array of duplicates in R


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
library(data.table)
setDT(mydat)

mydat[, tail(.SD, 1), PROB_POSTR_KM]
#    PROB_POSTR_KM   a    b
# 1:        378884 7.8 69.5
# 2:        404136 8.0 70.0

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...