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: "Liaw, Andy" <andy_liaw@merck.com>
Date: Mon, 22 Nov 2004 19:40:50 -0500
The functions tapply() and by() can be used for things like this.  E.g.,
 
meanBP1st3 <- tapply(dat$BP, dat$ID, function(x) mean(x[1:3]))
 
HTH,
Andy
-----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 6: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

 

------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system.
------------------------------------------------------------------------------

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