[R] Calendar in R-program

Spencer Graves spencer.graves at structuremonitoring.com
Tue Jan 4 19:14:18 CET 2011


       If all you want is a calendar "Date", the simplest may be the 
Date class in the base package.  Try help('as.Date').


       Dates and times can be extremely difficult to use for many 
reasons.  For example, some months have 30 days, others have 31, and 
February usually has 28 days, but every 4th year, it has 29, except if 
the year is a century year, except ... .  Times involve arithmetic to 
multiple bases.  In addition, there are occasional leap seconds 
introduced by irregularities in the rotation of the earth.  Then don't 
forget timezones and holidays, which vary between countries and 
sometimes between regions within a country.  Holidays further depend on 
the occupation.  Financial markets have their own rules.


       This complexity is met by a wide range of alternative systems in 
R for coding dates and times.  A great overview of the options appeared 
in R News a few years ago.  To find it,
go to "r-project.org" -> "The R Journal" -> Archive -> "Table of 
Contents (all issues)" -> Search for "date".  The second match should be 
"Gabor Grothendieck and Thomas Petzoldt. R Help Desk: Date and time 
classes in R. R News, 4(1):29-32, June 2004".


       There have been many additions since 2004.  Probably the quickest 
way to find other options is to use the sos package.


library(sos)
(cndr <- ???calendar)
#found 238 matches;  retrieving 12 pages
# This will open a table in a web browser showing the 238 matches
# sorted by package.
# A function from the "lubridate" package is match # 229 on this list.


       The "sos" package also has a vignette, which provides examples of 
how to combine searches, write results to an Excel file with the first 
sheet being a summary by package, etc.


       Hope this helps.
       Spencer


On 1/4/2011 9:32 AM, Mark Sharp wrote:
> Look at the lubridate package from Hadley Wickham for great basic routines for handling date objects.
>
> Mark
> R. Mark Sharp, Ph.D.
> msharp at sfbr.org<mailto:msharp at sfbr.org>
>
>
>
>
> On Jan 4, 2011, at 8:02 AM, LOON88 wrote:
>
>
> Hey.
> I have to do calendar in program R. I was looking for examples on this forum
> but havent found it. Can someone help me in this thing ? I would be really
> appreciate for that. Calendar should be the same as we have in Windows but I
> really dont know how to begin it. Hope u can show me the best way to do it.
> Cheers
> --
> View this message in context: http://r.789695.n4.nabble.com/Calendar-in-R-program-tp3173566p3173566.html
> Sent from the R help mailing list archive at Nabble.com<http://Nabble.com>.
>
> ______________________________________________
> R-help at r-project.org<mailto: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.
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
>


-- 
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567



More information about the R-help mailing list