| To: | "Schwarz,Paul" <PSchwarz@gcrinsight.com> |
|---|---|
| Subject: | Re: how to extract entire rows from a data frame based on a index |
| From: | David L Lorenz <lorenz@usgs.gov> |
| Date: | Thu, 17 Nov 2005 07:26:15 -0600 |
| Cc: | s-news@lists.biostat.wustl.edu, s-news-owner@lists.biostat.wustl.edu |
| In-reply-to: | <89C7DEAADB79564DB278694EB2417CCE5FAA3C@CHOCOLATE.GCRInsight.com> |
|
Paul, The aggregate() function should do what you want. Look at the aggregate.data.frame() documentation. The data would need to be sorted by date or ID and date to work correctly. Dave
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 -------------------------------------------------------------------- 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 |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | how to extract entire rows from a data frame based on a index variable?, Schwarz,Paul |
|---|---|
| Next by Date: | Re: how to extract entire rows from a data frame based on a index variable?, Biggerstaff, Brad J. |
| Previous by Thread: | how to extract entire rows from a data frame based on a index variable?, Schwarz,Paul |
| Next by Thread: | Re: how to extract entire rows from a data frame based on a index variable?, Biggerstaff, Brad J. |
| Indexes: | [Date] [Thread] [Top] [All Lists] |