-----Original Message-----
From: Zagar Tina [mailto:TZagar at onko-i.si]
Sent: Monday, February 13, 2006 3:42 PM
To: BXC (Bendix Carstensen)
Subject: transforming number from cal.yr() back to date
Dear Bendix,
I am working with function Lexis() included in Epi package so I have
to transform all dates into numbers using function cal.yr(). I am
having problems with transforming these numbers back to dates. I have
tried with transforming cal-yr()'s number to R date first but
obviously I am doing something terribly wrong. Can you help me? I am
sending you my code (which does not work):
# the original date is 07.04.1994
a = cal.yr("07.04.1994" , format="%d.%m.%Y")
a # result is 1994.263
# 'a1' is 'a' transformed into R date (number of days)
a1 = round(as.numeric(as.Date( as.character(paste("01.01.",
round(a))) , format="%d.%m.%Y"))+ 365.25 * (a - round(a))) # 'a2' is R
date transformed from original date 07.04.1994 a2 =
as.numeric(as.Date( as.character("07.04.1994") ,
format="%d.%m.%Y")) # a1 and a2 are the same a1 - a2 # result is 0 #
but converting a1 and a2 back to ordinary dates does not work
as.date(a1) # result is 6Apr84
as.date(a2) # result is 6Apr84
I hope my question is not too stupid... Mybe only last step is false
"as.date(a1)"? Thank you for your answer.
Best regards,
Tina Zagar.
<><><><><><><><><><><><><><>
Tina ?agar
Institute of Oncology Ljubljana
Epidemiology and Cancer Registries
Zalo?ka cesta 2
SI-1000 Ljubljana
Slovenia
E-mail: tzagar at onko-i.si
Tel.: +386 1 5879 562
<><><><><><><><><><><><><><>