Learn R Programming

dint (version 2.1.4)

as_yearqtr: Coerce to zoo yearqtr objects

Description

as_yearqtr() and as_yearmon() are included for interoperability with zoo::yearqtr(), an alternative year-quarter format that is based on a decimal representation as opposed to dint's integer representation of year-quarters. as_yearweek() follows a similar idea, but there is no corresponding S3 class in zoo. These functions were included for cases where you need a continuous representation of date_xx objects other then base::Date() (for example, they are used by scale_date_xx)

Usage

as_yearqtr(x)

# S3 method for date_yq as_yearqtr(x)

# S3 method for yearqtr as_yearqtr(x)

as_yearmon(x)

# S3 method for date_ym as_yearmon(x)

# S3 method for yearmon as_yearmon(x)

as_yearweek(x)

# S3 method for date_yw as_yearweek(x)

# S3 method for yearweek as_yearweek(x)

Value

a zoo::yearqtr, zoo::yearmon or dint::yearweek vector.

Arguments

x

any R object

Examples

Run this code
q <- date_yq(2016, 1:4)
as.numeric(q)
qzoo <- as_yearqtr(q)
as.numeric(qzoo)

m <- date_ym(2016, 1:12)
as.numeric(m)
mzoo <- as_yearmon(m)
as.numeric(mzoo)

w <- date_yw(2016, 1:52)
as.numeric(w)
wzoo <- as_yearweek(w)
as.numeric(wzoo)

Run the code above in your browser using DataLab