Hi:
Since you tried several functions (reasonably so IMO), here is how
they would work in this problem, in addition to the solutions already
supplied.
Some data massaging before starting, taking your data as input, saved
into an object named visits:
visits <- structure(list(unique_id = c(1L, 1L,
Try this:
require(zoo)
lvd <- tapply(df$visit_date, df$unique_id, max)
index <- tapply(df$visit_date, df$unique_id)
df$last_visit_date <- as.Date(lvd[index])
Jean
Kathleen Rollet wrote on 08/24/2011 04:15:45 PM:
>
> Dear R users,
>
> I am encoutering the following problem: I have a dataset wit
On Aug 24, 2011, at 5:15 PM, Kathleen Rollet wrote:
Dear R users,
I am encoutering the following problem: I have a dataset with a
'unique_id' and different 'visit_date' (formatted as.Date, "%d/%m/
%Y") per unique_id. I would like to create a new variable with the
most recent date of visit
Dear R users,
I am encoutering the following problem: I have a dataset with a 'unique_id' and
different 'visit_date' (formatted as.Date, "%d/%m/%Y") per unique_id. I would
like to create a new variable with the most recent date of visit per unique_id
as shown below.
unique_id visit_date
4 matches
Mail list logo