rip_month() extracts the month from a date or datetime object.

rip_month(x)

Arguments

x

<Date / POSIXct / POSIXlt>

The vector to extract the month from.

Value

An integer vector the same size as x containing the months. 1 aligns with January, and 12 is December.

Examples

x <- as.Date("2019-01-01") rip_month(x)
#> [1] 1
# Identical dates, but in different months a <- as.POSIXct("1969-12-31 19:00:00", tz = "America/New_York") b <- as.POSIXct("1970-01-01 00:00:00", tz = "UTC") identical(as.numeric(a), as.numeric(b))
#> [1] TRUE
rip_month(a)
#> [1] 12
rip_month(b)
#> [1] 1