[R] day of the year for chron objects

Jannis bt_jannis at yahoo.de
Fri Jun 8 13:16:51 CEST 2012


The following appears to be pretty "standard" (though not included in 
chron) to me:

  b = ISOdate(2001,12,12)
  format(b, '%j')

or is that what you refer to with
"I know I can make my own using julian" ?


No idea about the other questions though ...


Jannis


On 08.06.2012 10:01, Agustin Lobo wrote:
> Hi!
> Is not there an standard R function to retrieve the day of the year
> (since 1st Jan of the same year)?
> I know I can make my own using julian, but find it weird that having
> days(), months() etc doy() does not exist as an standard function.
>
> Also, is the following not a bit inconsistent?
>
>> a<- chron("20100506",format="ymd")
>> a
> [1] 100506
>> years(a)
> [1] 2010
> Levels: 2010
>
> but instead have to cast to Date to apply julian:
>> julian(a)
> Error in names(d) : 'd' is missing
>> julian(as.Date(a))
> [1] 14735
> attr(,"origin")
> [1] "1970-01-01"
>
> Thanks
>
> Agus
>



More information about the R-help mailing list