Hi Thomas,

Many thanks for the below, looks like it would do just the trick.  I have
also also copied your reply in a response to the R-devel discussion of same,
will forward it to you.

Forgive my ignorance on this, I have windows XP, so how do I get started -
have not sourced code before in R so do I just copy all the files in the
below directory to my R library and then source convdates.R from there or?

Thanks again,
Amy


On Wed, Jan 7, 2009 at 5:00 PM, Thomas Lumley <tlumley@u.washington.edu>wrote:

>
> I looked at the C code from Project Pluto that Hosseini references, and
> wrote R wrappers for it.  The C and R code are at
>  http://faculty.washington.edu/tlumley/calendars
>
> I haven't turned it into a package (anyone who wants to is welcome), and it
> has only been tested to a limited extent and only on Mac OS.
>
> Build the C code with
>  R CMD SHLIB convdates.c date.cpp
> then source("convdates.R")
>
> This sets up an OtherDate class that can hold Persian, Islamic, Hebrew, and
> the other calendars that the C code supports, with methods to convert to and
> from Date.
>
> It should be possible to translate the C algorithms into straight R with
> little loss of efficiency, but that looked like more than an hour's work.
>
>      -thomas
>
>
>
>
> On Wed, 7 Jan 2009, BXC (Bendix Carstensen) wrote:
>
>  Hi Amy,
>> you probaly already have visited:
>> http://www.codeproject.com/KB/cs/JalaliCalendar.aspx
>> where the Iranian guy Homam Hosseini provides a discussion of the
>> conversion, and some C code to do it.
>>
>> I am a C ignorant, but surely someone in the R-community would be able to
>> take this code (and in collaboration with Homam) provide a function that
>> converts Iranian / Jalali dataes to and from the Gregorian Date class??
>>
>> Best regards
>> Bendix
>>
>>  -----Original Message-----
>>> From: r-sig-epi-bounces@stat.math.ethz.ch
>>> [mailto:r-sig-epi-bounces@stat.math.ethz.ch] On Behalf Of Amy Mikhail
>>> Sent: 7. januar 2009 12:40
>>> To: r-sig-epi@stat.math.ethz.ch
>>> Subject: [R-sig-Epi] Converting dates from the Persian
>>> calendar to Gregorian
>>>
>>> Dear Epi list,
>>>
>>> This is not a strictly epidemiological question, but an issue
>>> that anyone might face if presented with a dataset containing
>>> dates in a non-gregorian format.
>>>
>>> I am currently developing a database (in MS Access) for a
>>> public health study, the results of which I intend to analyse
>>> in R.  I have a small problem, in that the date each patient
>>> visits the clinic will be entered into the database in the
>>> Persian  / Jalali calendar format - e.g. today's
>>> date in the Persian calendar is 18.10.1387.   For the
>>> analysis however I
>>> need these dates to be converted to Gregorian, so that I can
>>> have months on the x axis of plots, etc.
>>>
>>> Does anyone know of a function / some code already written
>>> that could do this conversion in R?  It is much too complex
>>> for me to figure out (since the Persian new year starts on
>>> 21st March, and although there are also 12 months they have
>>> different lengths to gregorian months).  I'm guessing it
>>> would require loops and such but this is beyond my current
>>> level of R knowledge.
>>>
>>> I have found some online tools that do the conversion of
>>> individual dates, but there seems to be nothing out there
>>> that would convert a whole dataset's worth of dates.
>>>
>>> Any suggestions much appreciated,
>>> With best wishes,
>>> Amy
>>>
>>>
>>> --
>>> Amy Mikhail
>>> Program Manager, ACTc Afghanistan Malaria Project London
>>> School of Hygiene & Tropical Medicine HPRO, Charahi-e-Shahid,
>>> Shar-e-Naw, Kabul, Afghanistan
>>>
>>> Email (Afg): amy.mikhail@googlemail.com
>>> Email (UK): Amy.Mikhail@lshtm.ac.uk
>>> Tel (Afg): +93 (0)706 126627
>>> Tel (UK): +44 (0)781 4176107
>>>
>>>        [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-Epi@stat.math.ethz.ch mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-epi
>>>
>>>  _______________________________________________
>> R-sig-Epi@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-epi
>>
>>
> Thomas Lumley                   Assoc. Professor, Biostatistics
> tlumley@u.washington.edu        University of Washington, Seattle
>
>
>


-- 
Amy Mikhail
Program Manager, ACTc Afghanistan Malaria Project
London School of Hygiene & Tropical Medicine
HPRO, Charahi-e-Shahid, Shar-e-Naw, Kabul, Afghanistan

Email (Afg): amy.mikhail@googlemail.com
Email (UK): Amy.Mikhail@lshtm.ac.uk
Tel (Afg): +93 (0)706 126627
Tel (UK): +44 (0)781 4176107

	[[alternative HTML version deleted]]

