period_cd: Numeric codes for periods

View source: R/period_cd.R

period_cdR Documentation

Numeric codes for periods

Description

Convenient time codes for analysis.

Usage

period_cd(x, period = "fy")

cm_to_fm(f)

cm_to_cq(f)

cm_to_fq(f)

cm_to_cy(f)

cm_to_fy(f)

cq_to_fq(f)

cq_to_fy(f)

cq_to_cy(f)

fm_to_cm(f)

fm_to_cq(f)

fm_to_fq(f)

fm_to_cy(f)

fm_to_fy(f)

fq_to_cq(f)

fq_to_cy(f)

fq_to_fy(f)

periods(x, origin = Sys.Date(), interval = 6, period_nm = FALSE)

Arguments

x

Date, POSIXct or POSIXt. numeric and integer for periods()

period

Options are "fy" (default), "fy", "cy", "fq", "cq", "fm", "cm"

f

Time code. Output of period_cd()

origin

Start of the period. Must be the same object type as x

interval

Interval between periods.

period_nm

If TRUE, returns the first point (day, time or number) of the period

Details

cm_to_fm() - Convert calendar month codes to financial month codes

cm_to_cq() - Convert calendar month codes to calendar quarter codes

cm_to_fq() - Convert calendar month codes to financial quarter codes

cm_to_cy() - Convert calendar month codes to calendar year codes

cm_to_fy() - Convert calendar month codes to financial year codes

cq_to_fq() - Convert calendar quarter codes to financial quarter codes

cq_to_cy() - Convert calendar quarter codes to financial year codes

cq_to_cy() - Convert calendar quarter codes to calendar year codes

fm_to_cm() - Convert financial month codes to calendar month codes

fm_to_cq() - Convert calendar month codes to calendar quarter codes

fm_to_fq() - Convert calendar month codes to financial quarter codes

fm_to_cy() - Convert financial month codes to calendar year codes

fm_to_fy() - Convert financial month codes to financial year codes

fq_to_cq() - Convert financial quarter codes to calendar quarter codes

fq_to_cy() - Convert financial quarter codes to calendar year codes

fq_to_fy() - Convert financial quarter codes to financial year codes

Convert dates to custom intervals

Value

numeric. Date, POSIXct or POSIXt for periods()

Examples

dt <- Sys.Date()
period_cd(dt)
period_cd(dt,"cy")
period_cd(dt,"fq")
period_cd(dt,"cq")
period_cd(dt,"fm")
period_cd(dt,"cm")
period_cd(dt,"fd")
period_cd(dt,"cq")
cm_to_fm("201204")
cm_to_fm("201201")
cm_to_cq("201201")
cm_to_cq("201211")
cm_to_fq("201201")
cm_to_fq("201211")
cm_to_cy("201204")
cm_to_cy("201201")
cm_to_fy("201204")
cm_to_fy("201201")
cq_to_fq("20124")
cq_to_fq("20121")
cq_to_fy("20124")
cq_to_fy("20121")
cq_to_cy("20124")
cq_to_cy("20121")
fm_to_cm("201204")
fm_to_cm("201201")
fm_to_cq("201201")
fm_to_cq("201211")
fm_to_fq("201201")
fm_to_fq("201211")
fm_to_cy("201204")
fm_to_cy("201201")
fm_to_fy("201204")
fm_to_fy("201201")
fq_to_cq("20124")
fq_to_cq("20121")
fq_to_cy("20124")
fq_to_cy("20121")
fq_to_fy("20124")
fq_to_fy("20121")
date <- as.Date("2019-01-05")
periods(x = date, origin = date)
periods(x = Sys.Date(), origin = date)
periods(x = Sys.Date(), origin = date, period_nm = TRUE)

OlisaNsonwu/jurithy documentation built on Nov. 28, 2023, 3:39 a.m.