[R] Finding the two most recent dates

Newbie19_02 nvanzuydam at gmail.com
Mon Sep 6 12:45:56 CEST 2010


Dear R help,

I have the following data frame:

structure(list(prochi = c("ind_1", "ind_1", "ind_1", 
"ind_1", "ind_1", "ind_1", "ind_1", "ind_1", 
"ind_1", "ind_1"), date_1st_event = structure(c(14784, 
14784, 14784, 14784, 14784, 14784, 14784, 14784, 14784, 14784
), class = "Date"), bp_date = structure(c(12660, 14571, 13392, 
13080, 12012, 13080, 13894, 14622, 12654, 13894), class = "Date"), 
    SBP = c(135L, 160L, 135L, 153L, 150L, 153L, 151L, 126L, 150L, 
    151L), DBP = c(85L, 80L, NA, 79L, 82L, 79L, 76L, 60L, 82L, 
    91L)), .Names = c("prochi", "date_1st_event", "bp_date", "SBP", 
"DBP"), row.names = 108:117, class = "data.frame")

It consists of repeated measures for the same individual.  What I want to do
is find the two most recent blood pressure readings (SBP and DBP) using
date_1st_event and bp_date.  What I would do to find the most recent date is
to subtract date_1st_event-bp_date and then aggregate by min.  I'm not sure
how to find the two most recent dates.  

Are there some functions that can help me or will I have to write a function
from scratch.  Any help just to point me in the right direction.

Thanks,
Natalie
-- 
View this message in context: http://r.789695.n4.nabble.com/Finding-the-two-most-recent-dates-tp2528185p2528185.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list