end_of_period | R Documentation |
Functions for manipulating vectors that inherit from class
POSIXt
or Date
.
is_leapyear(x)
first_of_month(x)
end_of_month(x, shift = 0L)
end_of_previous_month(x)
first_of_year(x)
end_of_year(x, shift = 0L)
end_of_previous_year(x)
end_of_quarter(x, shift = 0L)
day_of_month(x)
day_of_month(x) <- value
mday(x)
mday(x) <- value
second(x, as.character = FALSE)
minute(x, as.character = FALSE)
hour(x, as.character = FALSE)
month(x, as.character = FALSE)
year(x, as.character = FALSE)
x |
a vector of class |
value |
a vector of integers |
shift |
integer |
as.character |
logical |
end_of_month
returns the last calendar day of a given month. If
shift
is positive, then shift months
into the future; if
negative, the end of previous months. end_of_month(x, -1)
is
equivalent to end_of_previous_month(x)
. end_of_year
works in the same way, but for calendar years.
mday
is a wrapper for day_of_month
.
Vectors of class Date
or POSIXct
; or logical
Enrico Schumann
B.D. Ripley and K. Hornik. Date-Time Classes. R-News, 1(2):8–12, 2001.
DateTimeClasses
Many useful functions are also in package chron.
## vectorisation: x *or* shift (but not both!)
end_of_month(as.Date("2013-01-15"), shift = c(-1, 0, 1))
end_of_month(as.Date("2013-01-15") + 0:100)
day_of_month(d <- as.Date("2013-01-22"))
day_of_month(d) <- 5
d
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.