s-news
[Top] [All Lists]

mergin subsets of dataframes

To: "s-news@lists.biostat.wustl.edu" <s-news@lists.biostat.wustl.edu>
Subject: mergin subsets of dataframes
From: Pedram Sendi <psendi@uhbs.ch>
Date: Tue, 20 May 2003 11:34:21 +0200
Encoding: 60 TEXT
Organization: IKE
Reply-to: "psendi@uhbs.ch" <psendi@uhbs.ch>
Dear All,

I have 2 data frames, in dataframe 1 each patient is contained in one row, 
defined by a unique patient id and a follow-up date; in data set 2, there 
are multiple rows for the same patient with different labdates and 
labresults (CD4), e.g.

Dataframe 1

id      fupdate
1       01/02/2003
2       03/02/2003
3       05/03/2003
4       06/04/2003


Datafram 2

id      labdate         CD4

1       date1           200
1       date2           150
1       etc.            300
1
2
2
2
2
2
3
3
3
4
4
4
4

I would like to include for each patient as an additional column in 
Dataframe 1 that single labdate (inlcuding the corresponding CD4 count and 
other potential variables in the same row) of Dataframe 2 which is closest 
(within three months difference) to the fupdate in Dataframe 1.

Any hints how to do this in s-plus is greatly appreciated.

Thanks in advance,
Pedram


Pedram Sendi, MD, DSc
Institute for Clinical Epidemiology & Division of Infectious Diseases
Institut fur klinische Epidemiologie & Abteilung fur Infektiologie
Basel University Hospital
Kantonsspital Basel
Hebelstrasse 10, 3rd Floor
CH-4031 Basel
Switzerland
Phone: +41 61 265 31 02
Fax: +41 61 265 31 09
E-Mail: psendi@uhbs.ch




<Prev in Thread] Current Thread [Next in Thread>