year-month-day-methods {mondate} | R Documentation |
The methods in this section facilitate mondate
construction
using the year, month, and day numbers of the date
(as those numbers would be seen in the character representation of the date,
i.e.., "January" = 1 and the first day of a month = 1).
year(x, ...) month(x, ...) day(x, ...) ymd(x) mondate.mdy(m, d, y, displayFormat=.default.displayFormat, timeunits=.default.timeunits, ...) mondate.ymd(y, m, d, displayFormat=.default.displayFormat, timeunits=.default.timeunits, ...)
x |
an object of class "mondate." |
m |
the month: 1, ..., 12.
If "missing" and |
d |
the day: 1, ..., 31, depending on the month.
If "missing" in the case of |
y |
the four-digit year. |
displayFormat |
the date format with which to display
the |
timeunits |
character string "months" (default), "years", or "days" indicating the units in which date arithmetic will be carried out. |
... |
For |
year
returns the year number (e.g., 2000) as a numeric
.
month
returns the month number (1, ..., 12) as a numeric
.
day
returns the day of the month as a numeric
starting with 1.
ymd
returns a matrix with the number of rows equal to the
length of x
and with appropriately-named
columns 1 through 3 holding the year
,
month
, and day
, respectively.
mondate.mdy
and mondate.ymd
return "mondates" with the given
month, day, and year.
Arguments m
, d
, and y
may have length > 1;
the usual recycling rules apply.
The mondate.ymd
function has a bit more functionality.
If d
is "missing" in a call to mondate.ymd
then the date
returned will be the last day of month m
in year y
.
If m
is also missing,
then the date returned will be the last day of the year.
If any of y
, m
, or d
are NA
the result will be an all-NA
vector.
And if y=+-Inf
then the result will be an "infinite" mondate vector,
overriding other rules included herein.
The length of a vector result is determined
using the usual recycling rules
as though a valid, finite scalar had been inserted instead of
NA
or +-Inf
.
See the Examples section.
M<-mondate.mdy(6,30,2008) year(M) # 2008 month(M) # 6 day(M) # 30 mondate.ymd(2008,6,30) # ditto mondate.ymd(2008,6) # ditto; 'day' argument is "missing" so # returns the last day of the month mondate.ymd(2008,1:12) # all month-ends of 2008, a leapyear # year-ends 2001 through 2010, displaying only the 4-digit year when shown mondate.ymd(2001:2010, displayFormat="%Y") mondate.ymd(2010:2012, NA) # NA mondate vector of length 3 mondate.ymd(Inf,11,31) # An infinite mondate even though only 30 days in # November