span_date: Wrapper around 'seq.Date'.

View source: R/span_date.R

span_dateR Documentation

Wrapper around seq.Date.

Description

Quickly create a sequence of dates from minimal specifications.

Usage

span_date(from, to = NULL, len_out = NULL, by = NULL)

Arguments

from

Integer or character of length 4 (yyyy), 6 (yyyymm), or 8 (yyymmdd). Indicating the start value of the sequence.

to

Integer or character of length 4 (yyyy), 6 (yyyymm), or 8 (yyymmdd). Optional.

len_out

The desired length of the sequence. Optional.

by

The desired interval. Optional.

Details

Minimal specification of dates, sets unspecified date parts to default values. These are 01 for both month and day.

In addition to from, either to or len_out must be specified. If by is not specified, span_date will set the interval to the highest of the specified date parts in either from or to. For example, if they are 2011 and 2015 it will be "year", if they are 2011 and 201501 it will be "month".

Value

An object of class Date.

Examples

# using "to" argument
span_date(2011, 2015)
span_date(201101, 201501)
span_date(2011, 2015, by = "month")
span_date(2011, 201501)
span_date(20111225, 2012)

# using "len_out" argument
span_date(2011, len_out = 4)
span_date(201101, len_out = 4)
span_date(20110101, len_out = 4)
span_date(20110101, len_out = 4, by = "month")

padr documentation built on Nov. 23, 2022, 5:06 p.m.