[R] Matching when each subject has multiple records

Sorkin, John j@ork|n @end|ng |rom @om@um@ry|@nd@edu
Thu Sep 18 17:03:15 CEST 2025


Naresh,

I appreciate your reply.

In my original posting, I neglected to mention that I want to propensity score match the two groups. I don't think you suggestion will help me propensity score match my data. Am I missing something?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine, University of Maryland School of Medicine;
Associate Director for Biostatistics and Informatics, Baltimore VA Medical Center Geriatrics Research, Education, and Clinical Center;
PI Biostatistics and Informatics Core, University of Maryland School of Medicine Claude D. Pepper Older Americans Independence Center;
Senior Statistician University of Maryland Center for Vascular Research;

Division of Gerontology and Paliative Care,
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
Cell phone 443-418-5382





________________________________________
From: R-help <r-help-bounces using r-project.org> on behalf of Naresh Gurbuxani <naresh_gurbuxani using hotmail.com>
Sent: Thursday, September 18, 2025 10:10 AM
To: r-help using r-project.org <r-help using 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 using 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.




More information about the R-help mailing list