# Re: [R] Count days of current year

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue, 25 Nov 2008 08:20:05 -0500

As yearmon represents year/month as year + fraction of year adding 1 gives next year. The first output below gives an answer of class "difftime" whereas the the second solution is "numeric":

> library(zoo)
> year <- 2000:2010
> d <- as.Date(as.yearmon(year)+1) - as.Date(as.yearmon(year))
> d

Time differences in days
[1] 366 365 365 365 366 365 365 365 366 365 365

> # or to get a numeric answer:
> as.double(d, units = "days")

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

On Mon, Nov 24, 2008 at 2: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