Hi Ted,

>
> Many thanks for the suggestion.  I'm afraid I'm not from a programming
> background at all, hence I wouldn't even know what software to paste the
> c-code into, much less how to apply it to my column of dates.  I have been
> using R for a few years but very much as a user rather than developer - so
> I'm comfortable with R syntax but syntax in other languages is pretty alien
> to me.  Actually the data will be entered into an MS Access database - I've
> tried asking whether there is a suitable workaround in MS access forums as
> well, but so far no joy - not sure if it is possible to somehow paste the C
> code in there - if so would need some detailed instructions on how to do
> this.
>
> I hadn't thought to check out the R extensions before, if this is
> straightforward I'll give it a go...
>
> Thanks and best wishes,
> Amy
>
>
> On Wed, Jan 7, 2009 at 5:20 PM, Ted Byers <r.ted.by...@gmail.com> wrote:
>
>> On Wed, Jan 7, 2009 at 10:23 AM, Amy Mikhail 
>> <amy.mikh...@googlemail.com>wrote:
>>
>>> Dear list,
>>>
>>> I will shortly have some data that contains numeric dates in the Persian
>>> /
>>> Jalali calendar format, which I would like to convert to gregorian.  At
>>> the
>>> moment there doesn't seem to be a function for this in R, but it would be
>>> great if someone could come up with same - I would attempt it but the
>>> algorithm is very complex and this is also way beyond my fairly
>>> rudimentary
>>> knowledge of R.
>>>
>>> How do you feel about mixed language programming?
>>
>> I don't know anything about Jalali dates, but I took the time to check and
>> found that Perl has modules that handle this (use CPAN or, on windows, PPM
>> to find them).  However, like the C code you found, it will convert values a
>> date at a time.  I don't know why this would be an issue.
>>
>> I have never tried to use either C or perl from within R, but if you can
>> handle that, it would be trivial to apply these function calls to each value
>> in a vector (or array if you prefer) in functions written in either C/C++ or
>> perl.  In both C++ using STL and Perl, that would require only one line of
>> code, and perhaps a couple more in C to manage the required loop if you
>> restrict yourself to C, ignoring the benefits of C++.
>>
>> If I were doing this, I'd do it even before storing the data in my
>> database, or at least before importing it into a dataframe in R, but that is
>> primarily because I am still learning R, having used it for only a few
>> months, rather than a few years using perl and 15+ years using C++.  I am so
>> early on my R learning curve that I haven't yet looked at writing code in
>> C++ or Perl that is to be called by R.  While I haven't read through it in
>> enough detail to play seriously with it, the method for using such code from
>> with R described in "Writing R Extensions" seems simple enough.  Instead
>> of writing the code to implement your 'complex' algorithm, why not just use
>> the code you've found, or that available in CPAN (I don't know about you,
>> but I hate reinventing the wheel), and create the trivial extension needed
>> following the instructions in "Writing R Extensions", or do it to the raw
>> data before you import it into R?
>>
>> HTH
>>
>> Ted
>>
>
>
>
> --
> 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.mikh...@googlemail.com
> Email (UK): amy.mikh...@lshtm.ac.uk
> Tel (Afg): +93 (0)706 126627
> Tel (UK): +44 (0)781 4176107
>



-- 
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.mikh...@googlemail.com
Email (UK): amy.mikh...@lshtm.ac.uk
Tel (Afg): +93 (0)706 126627
Tel (UK): +44 (0)781 4176107

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to