probably easy to do w/ Boost DateTime http://www.boost.org/doc/libs/1_37_0/doc/html/date_time.html
for which there is already an R package in development: http://repo.or.cz/w/RBoostDateTime.git I'm happy to write a small wrapper to do what you want if you can offer a pseudocode example of the conversion function. -Whit On Wed, Jan 7, 2009 at 12: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<file:///C:/Program%20Files/R/R-2.8.0/doc/manual/R-exts.html>" > 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<file:///C:/Program%20Files/R/R-2.8.0/doc/manual/R-exts.html>", > or do it to the raw data before you import it into R? > > HTH > > Ted > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel