Dear Tony Plate and Sundar Dorai-Raj
Thanks for your time show to me your methods on calculating age form date in
S-plus.
For the benefit of every one I include your recomendation
1)
x <- timeDate("01012000", "%2m%2d%4Y") date()
[1] "Thu Aug 19 14:45:38 MDT 2004"
x2 <- timeDate("08192004", "%2m%2d%4Y") x
[1] 2000/01/01
x2
[1] 2004/08/19
timeSpan(x2 - x, format=format.timeSpan$"1y")
[1] \"4y 232d 0h 0m 0s 0MS\"
2)
You'll have to convert the values to character and prepend a "0" to the
beginning those elements that represent dates before October 1, assuming
month/day/year.
x <- 12000 + 1000000 * 1:12
x <- paste(ifelse(x < 10000000, "0", ""), x, sep = "")
x.td <- timeDate(x, "%2m%2d%4Y")
2. if the time is the Birth Date. How can I calculate the age?
for example; from 01/01/2000 to 4.x year of age
today <- timeDate(date(), "%w %m %d %H:%M:%S %Z %Y")
as.numeric(today - x.td)/365.25
|