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
> 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 - 13:22:57 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 - 14:00:28 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