Re: [R] Count days of current year

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue, 25 Nov 2008 09:52:21 -0500

Similarly tis and chron have nearly the identical function:

> library(tis)
> 365 + isLeapYear(2000:2010)

 [1] 366 365 365 365 366 365 365 365 366 365 365

> isLeapYear

function (y)
y%%4 == 0 & (y%%100 != 0 | y%%400 == 0)
<environment: namespace:tis>

> library(chron)
> 365 + leap.year(2000:2010)
 [1] 366 365 365 365 366 365 365 365 366 365 365
> leap.year

function (y)
{

    if (inherits(y, "dates"))

        y <- month.day.year(as.numeric(y), origin. = origin(y))$year     y%%4 == 0 & (y%%100 != 0 | y%%400 == 0) }
<environment: namespace:chron>

On Tue, Nov 25, 2008 at 9:38 AM, hadley wickham <h.wickham_at_gmail.com> wrote:
> Why not write it yourself?
>
> days_in_year <- function(year) {
> 365 + (year %% 4 == 0) - (year %% 100 == 0) + (year %% 400 == 0)
> }
>
> This should work for any year in the Gregorian calendar.
>
> Hadley
>
> On Mon, Nov 24, 2008 at 1:25 PM, Felipe Carrillo
> <mazatlanmexico_at_yahoo.com> wrote:
>> Hi:
>> Is there a function that counts the number of days of any given or current year based on the date?
>>
>> Felipe D. Carrillo
>> Supervisory Fishery Biologist
>> Department of the Interior
>> US Fish & Wildlife Service
>> California, USA
>>
>> ______________________________________________
>> 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.
>>
>
>
>
> --
> http://had.co.nz/
>
> ______________________________________________
> 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.
>



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. Received on Tue 25 Nov 2008 - 15:00:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 25 Nov 2008 - 15:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive