previous_year: Start and end of previous year

View source: R/previous_year.R

previous_yearR Documentation

Start and end of previous year

Description

Defines first and last date in n previous year

Usage

previous_year(x = Sys.Date(),
              n = 1, 
              part = getOption("timeperiodsR.parts"))

Arguments

x

Date object

n

Number of periods for offset

part

Part of period you need to receive, one of "all", "start", "end","sequence", "length". See details.

Details

You can get object of tpr class with all components or specify which component you need, use part for manage this option:

  • all - get all components

  • start - get only first date of period

  • end - get only last date of period

  • start - get vector of all dates in period

  • length - get number of dates in period

Value

Object of tpr class

Author(s)

Alexey Seleznev

See Also

For get next other periods see previous_week(), previous_month(), previous_quarter()

Examples

## To get start, end and sequence of previous year
previousyear <- previous_year()

## To get vector of date sequences 
previous_year(part = "sequence")
previous_year()$sequence
seq(previousyear)

## Get number of days of previous year
day_nums <- previous_year(part = "length")
previous_year()$length
length(previousyear)

timeperiodsR documentation built on April 20, 2023, 5:13 p.m.