Re: [R] Finding the two most recent dates

2010-09-06 Thread Newbie19_02
Dear all, Thanks very much for the replies and for the help. This whole data set consists of about 7000 individuals who have had multiple blood pressure measures taken over time so I just used one individual as an example. I'm sorry if it looked like homework...it isn't. Jim your solution wo

Re: [R] Finding the two most recent dates

2010-09-06 Thread jim holtman
Here is one way of doing it: > x prochi date_1st_eventbp_date SBP DBP 108 ind_1 2010-06-24 2004-08-30 135 85 109 ind_1 2010-06-24 2009-11-23 160 80 110 ind_1 2010-06-24 2006-09-01 135 NA 111 ind_1 2010-06-24 2005-10-24 153 79 112 ind_1 2010-06-24 2002-11-21 150

Re: [R] Finding the two most recent dates

2010-09-06 Thread Dieter Menne
Nathalie, your method of sending sample data is fine. dt = 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"), b

Re: [R] Finding the two most recent dates

2010-09-06 Thread Paul Hiemstra
Hi Natalie, By far the easiest thing to do is to convert the date to a special date class. See as.POSIXct for example. I'm not sure that 14784 means, nor what the data says in the bp_date column. Probably the two combine into a specific date? Once you've converted the columns into a POSIXct

[R] Finding the two most recent dates

2010-09-06 Thread Newbie19_02
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 = st