Dear Pravin
This might not be the most elegant solution but I think that will do the
trick for you (assuming that the observations in your dataset are sorted
ascending within each patient/date combination which seems to be the case).
dat1<-read.table("dat.txt", head = T)
dat1[,5]<-as.factor(paste(dat1$ID,dat1$DATE))
dat1
ID DATE TIME OBS X5
1 1 05/30/2000 7:00 100 1 1
2 1 05/30/2000 9:00 101 1 1
3 1 05/30/2000 11:00 102 1 1
4 1 05/30/2000 13:00 103 1 1
5 1 06/28/2000 8:00 100 1 2
6 1 06/28/2000 10:00 101 1 2
7 1 06/28/2000 12:00 102 1 2
8 1 06/28/2000 15:00 103 1 2
9 2 05/30/2000 7:00 101 2 1
10 2 05/30/2000 9:00 101 2 1
11 2 05/30/2000 10:00 102 2 1
12 2 05/30/2000 12:00 103 2 1
rename.col( obj=dat1, col=5, newColName="newid" )
first<-dat1[!duplicated(dat1$newid),]
first
ID DATE TIME OBS newid
1 1 05/30/2000 7:00 100 1 1
5 1 06/28/2000 8:00 100 1 2
9 2 05/30/2000 7:00 101 2 1
Cheers
Francisco
From: Pravin Jadhav <pravinj@gmail.com>
Reply-To: Pravin Jadhav <pravinj@gmail.com>
To: s-news@wubios.wustl.edu
Subject: [S] first record per occasion
Date: Sun, 28 Nov 2004 23:08:28 -0500
Hello,
I have repeated measures available for several individuals. There are
about 2-4 occassions per individual identified by the date of their
visit. Is there is any function that allows me to extract the first
observation per visit (basically, baseline at each visit).
The only information available in the dataset is (1) ID# (2) DATE (3)
TIME (4) OBS.
I have tried generating occassion number by finding unique date
(?unique) but there are a few individuals visiting on the same date.
So it didn't work.
Example:
ID DATE TIME OBS
1 05/30/2000 7:00 100
1 05/30/2000 9:00 101
1 05/30/2000 11:00 102
1 05/30/2000 13:00 103
1 06/28/2000 8:00 100
1 06/28/2000 10:00 101
1 06/28/2000 12:00 102
1 06/28/2000 15:00 103
2 05/30/2000 7:00 101
2 05/30/2000 9:00 101
2 05/30/2000 10:00 102
2 05/30/2000 12:00 103
I am interested in getting the following information
ID DATE TIME OBS
1 05/30/2000 7:00 100
1 06/28/2000 8:00 100
2 05/30/2000 7:00 101
Any commets are much appreciated.
Thanks.
Pravin
--
Pravin Jadhav
Graduate Student
Department of Pharmaceutics
MCV/Virginia Commonwealth University
DPE1/CDER/OCPB/Food and Drug Administration
Phone: (301) 594-5652
Fax: (301) 480-3212
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|