seq_month_ofeach_day: The sequence of month numbers for each day in the period from...

View source: R/time.R

seq_month_ofeach_dayR Documentation

The sequence of month numbers for each day in the period from - to

Description

The sequence of month numbers for each day in the period from - to

Usage

seq_month_ofeach_day(
  from = list(year = 1900, month = 1, day = 1),
  to = list(year = 1900, month = 12, day = 31),
  tz = "UTC"
)

Arguments

from

A list with three elements year, month, and day.

to

A list with three elements year, month, and day.

tz

a character string. The time zone specification to be used for the conversion, if one is required. System-specific (see time zones), but "" is the current time zone, and "GMT" is UTC (Universal Time, Coordinated). Invalid values are most commonly treated as UTC, on some platforms with a warning.

See Also

as.POSIXlt, seq.POSIXt

Examples

## Not run: 
month1 <- function() {
  as.POSIXlt(seq(
    from = ISOdate(1980, 1, 1, tz = "UTC"),
    to = ISOdate(2010, 12, 31, tz = "UTC"), by = "1 day"
  ))$mon + 1
}
month2 <- function() {
  seq_month_ofeach_day(
    from = list(1980, 1, 1),
    to = list(2010, 12, 31),
    tz = "UTC"
  )
}

if (requireNamespace("microbenchmark", quietly = TRUE)) {
  # barely any difference
  microbenchmark::microbenchmark(month1(), month2())
}

## End(Not run)

DrylandEcology/rSW2utils documentation built on Dec. 9, 2023, 10:44 p.m.