On Tue, Aug 07, 2007 at 03:53:28PM +0300, Lauri Nikkinen wrote:
> What is the best way to achieve a table which contains all days and months
> between years 2007-2020? I would like to calculate number of days in each
> month within those years (to data frame).

Here you go -- just replace length.out=3 by 24*12 for your twentyfour years:

   > as.POSIXlt(seq(as.Date("2007-02-01"), by="month", length.out=3)-1)$mday
  [1] 31 28 31
  > 

A sequence of month at the first of the next month, shifted back a day
gives the last one of that month -- converted to POSIXlt from which we
extract the day-of-the-month.

Hth, Dirk

-- 
Three out of two people have difficulties with fractions.

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to