| Title: | Year Months and Quarters |
|---|---|
| Description: | Operators to manipulate integers representing year months in the form YYYYMM, and year quarters in the form YYYYQQ. |
| Authors: | Steve Martin [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-2544-9480>) |
| Maintainer: | Steve Martin <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-12 05:19:29 UTC |
| Source: | https://github.com/marberts/ymq |
Operators to manipulate integers representing year months in the form YYYYMM, and year quarters in the form YYYYQQ.
Maintainer: Steve Martin [email protected]
https://github.com/marberts/yqm
Use m2q() to turn YYYYMM into YYYYQQ and q2m() to turn YYYYQQ into the first YYYYMM.
m2q(x) q2m(x)m2q(x) q2m(x)
x |
An integer vector of year months of the form YYYYMM, or year quarters of the form YYYYQQ. |
For q2m(), an integer vector of the form YYYYMM; for mq2(), an integer vector of the form YYYYQQ.
m2q(202103) q2m(202103) # Represent as the third month of the quarter q2m(202103) %+m% 2L # Represent as YYYYMMDD q2m(202103) * 100L + 1Lm2q(202103) q2m(202103) # Represent as the third month of the quarter q2m(202103) %+m% 2L # Represent as YYYYMMDD q2m(202103) * 100L + 1L
Count the number of integer digits in a number.
digits(x)digits(x)
x |
A numeric vector. |
An integer vector giving the number of integer digits in x.
digits(100) digits(100.1) digits(-0.1)digits(100) digits(100.1) digits(-0.1)
%+m% and %-m% add/subtract months for year months.
%m-m% finds the difference (in months) between year months.
%m:m% generates a sequence of year months.
Switching 'm' for 'q' does the same for year quarters.
e1 %+m% e2 e1 %-m% e2 e1 %m-m% e2 e1 %m:m% e2 e1 %+q% e2 e1 %-q% e2 e1 %q-q% e2 e1 %q:q% e2e1 %+m% e2 e1 %-m% e2 e1 %m-m% e2 e1 %m:m% e2 e1 %+q% e2 e1 %-q% e2 e1 %q-q% e2 e1 %q:q% e2
e1, e2
|
An integer vector of year months of the form YYYYMM, or year quarters of the form YYYYQQ. |
An integer vector of the form YYYYMM, or YYYYQQ.
# Add or subtract months/quarters 202101 %+m% 13 202101 %-m% 13 202101 %+q% 5 202101 %-q% 5 # Find the difference 202101 %m-m% 202202 202202 %q-q% 202101 # Make a sequence 202101 %m:m% 202202 202101 %q:q% 202202# Add or subtract months/quarters 202101 %+m% 13 202101 %-m% 13 202101 %+q% 5 202101 %-q% 5 # Find the difference 202101 %m-m% 202202 202202 %q-q% 202101 # Make a sequence 202101 %m:m% 202202 202101 %q:q% 202202