[R] How to convert day-month-year to Julian data number?

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jan 2 07:42:04 CET 2008


On Tue, 1 Jan 2008, jim holtman wrote:

> Is this what you want?
>
>> x <- c('5/5/2007', '12/31/2007')
>> # convert to day of year (Julian date) -- use POSIXlt
>> strptime(x, "%m/%d/%Y")$yday+1
> [1] 125 365

I don't think that is the usual definition of JDN: see
http://en.wikipedia.org/wiki/Julian_day.  A way to compute that version is

as.numeric(as.Date(x, format= "%m/%d/%Y")) + 2440588


> On Jan 1, 2008 4:59 PM, Nüzhet Dalfes <dalfes at gmail.com> wrote:
>> Hi,
>>
>> Is there a package for converting day-month-year type date to julian
>> day number (JDN)? I looked around and I couldn't find any (I am pretty
>> new to R...)
>>
>> Thanks and happy New Year to everybody!
>>
>>
>>
>>
>> H. Nüzhet Dalfes
>>
>> Professor,
>> Istanbul Technical University
>> Eurasia Institute of Earth Sciences
>> +90 (532) 206-1308
>> [dalfes at itu.edu.tr]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


More information about the R-help mailing list