s-news
[Top] [All Lists]

how to extract entire rows from a data frame based on a index variable?

To: <s-news@lists.biostat.wustl.edu>
Subject: how to extract entire rows from a data frame based on a index variable?
From: "Schwarz,Paul" <PSchwarz@gcrinsight.com>
Date: Wed, 16 Nov 2005 23:11:20 -0800
Thread-index: AcXrRhwYRu7I99hhQs+9rUCyH+EZSA==
Thread-topic: how to extract entire rows from a data frame based on a index variable?
Dear S-News readers,

I'm puzzling over how to solve the following problem. Let's say that I
have a data frame with possibly multiple observations (rows) per
sampling unit, in this case survey respondents. In addition to a
respondent ID variable, there is a date variable tracking the date the
information was collected. If I want to extract from this data frame
only the most recent observation (or the first, etc.) for each
respondent, how could I do this? I've been thinking about this problem
as a tapply()-like problem where the respondent ID would be the index
variable, but I haven't figured how to write a function to extract and
return entire rows. I would appreciate ideas or suggestions from fellow
list readers on how to solve this.

Thanks for your help.

-Paul

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