Skip to content
Prev 389116 / 398513 Next

how to find "first" or "last" record after sort in R

I prefer the duplicated() function, since the final code will be clear to a future reader. 
  (Particularly when I am that future reader).

last <- !duplicated(mydata$ID, fromLast=TRUE)  # point to the last ID for each subject
mydata$data3[last] <- NA

Terry T.

(I read the list once a day in digest form, so am always a late reply.)
On 9/10/21 5:00 AM, r-help-request at r-project.org wrote: