Just expanding on Brians code to something that will work for vector.
age_years - function(first, second)
{
lt - data.frame(first, second)
age - as.numeric(format(lt[,2],format=%Y)) -
as.numeric(format(lt[,1],format=%Y))
first
Daniel Brewer wrote:
I would like to be able to calculate the age of someone at a particular
date. Both dates are date objects. Here is what I have come up with:
floor(as.numeric(sampleInfo$Date.of.DIAGNOSIS-
sampleInfo$Date.of.birth)/365.25)
Is this the best approach?
No - leap
On Mon, 24 Sep 2007, Alberto Monteiro wrote:
Daniel Brewer wrote:
I would like to be able to calculate the age of someone at a particular
date. Both dates are date objects. Here is what I have come up with:
floor(as.numeric(sampleInfo$Date.of.DIAGNOSIS-
sampleInfo$Date.of.birth)/365.25)
3 matches
Mail list logo