[R] julian day form POSIXt object

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Sep 29 18:59:58 CEST 2011


On Thu, 29 Sep 2011, Jeff Newmiller wrote:

> On Thu, 29 Sep 2011, maxbre wrote:

[With the context excised, something the posting guide expressly asks 
not be done.]

>> yes, you are perfectly right, sorry for that but for me was not so 
>> clear the error message!

A phrase involving pots and kettles springs to mind.

The answer to the question asked was 'see ?julian'

>> ....and the third code example I posted (not working either) should be of
>> length one (if I'm not wrong again)
>> 
>> but most of all what is not included in my reproducible example and 
>> get a bit confused my question is the case when the variable "date" 
>> contains dates of many years and the objective is to count for each 
>> given year the julian date starting from the first day of the 
>> corresponding year
>
> So you aren't really interested in julian day, you are interested in day of 
> year.  Julian day maps all calendar time to number of days from a SINGLE 
> epoch (origin) which may differ from one problem to the next, but not from 
> one value to the next within the problem the way "beginning of year" changes 
> for each value.
>
>> how would you deal with this problem?
>
> test$doy <- as.POSIXlt(test$date)$yday+1

Perhaps, but as described without the +1.  The Julian day of the 
origin is taken to be day 0.

I think the OP wanted what ISO 8601:2004 calls 'ordinal dates' and of 
which Wikipedia says

'This system is sometimes incorrectly referred to as "Julian Date", 
whereas the astronomical Julian Date is a sequential count of the 
number of days since day 0 beginning 1 January 4713 BC Greenwich noon,
Julian proleptic calendar (or noon on ISO date -4713-11-24 which uses 
the Gregorian proleptic calendar with a year [0000]).'

>> thanks a lot for your help
>> 
>> max

-- 
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