________________________________________
From: R-help <r-help-bounces at r-project.org> on behalf of Naresh Gurbuxani
<naresh_gurbuxani at hotmail.com>
Sent: Thursday, September 18, 2025 10:10 AM
To: r-help at r-project.org <r-help at r-project.org>
Subject: [R] Fwd: Matching when each subject has multiple records
?
mydf <- data.frame(date = as.Date("2010-01-01") + sample(500, size =
20), subject = sample(c("A", "B", "C"), 20, replace = TRUE), first = FALSE)
mydf <- mydf[order(mydf$date),]
df_split <- split(mydf, f = mydf$subject)
df_split <- lapply(df_split, function(df) {df[1, "first"] <- TRUE; df})
mydf <- do.call(rbind, df_split)
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
https://www.r-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.