s-news
[Top] [All Lists]

Re: Data Extraction

To: "Bruce Green" <brucegreen@verizon.net>, <s-news@lists.biostat.wustl.edu>
Subject: Re: Data Extraction
From: "Yuying Gao" <ygao@pharsight.com>
Date: Mon, 22 Nov 2004 16:09:55 -0800
Thread-index: AcTQ7J8zAPUCYbK8SXSijHaMKc7S6wABA1vw
Thread-topic: [S] Data Extraction

Hello Bruce, hope this is helpful.

 

id_unique(data$id)

for (i in 1:length(id))

{

   datai_data[data$id==id[i],]

   outi_apply(datai[1:3,],2,mean,na.rm=T)

   if (i==1) assign("out",outi,where=1) else assign("out",rbind(out,outi),where=1)

}

 

Yuying Gao, MD, PhD

Pharsight Corporation

www.pharsight.com

 

 

-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu]On Behalf Of Bruce Green
Sent: Monday, November 22, 2004 3:40 PM
To: s-news@lists.biostat.wustl.edu
Subject: [S] Data Extraction

 

Hi,

I have a large dataset of 20000 rows that contains 180 individuals identified by a unique identification number. There are 5 columns of data with health status data in each column, and a different number of rows for each individual i.e. 5 rows for individual 1 and 20 rows for individual no. 2. I wish to extract the data from the first 3 rows for each individual and then perform a data function for each individual....i.e. what is the average blood pressure for individual 1 in the first 3 rows of their data?

 

I cannot seem to do this easily...any suggestions?

 

Regards

Dr Bruce Green

 

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