Skip to contents

Create an increasing ordered sequence of months

Usage

create_month(begin, ending)

Arguments

begin

character, begining month. See details for format.

ending

character, ending month. See details for format.

Value

A character vector with the sequence of month either in format "\

parameters.

Details

It creates a sequence of ordered months. The final format depends on the format of input parameters, that must be of the same type. If both begin and ending can be transform as integer between 1 and 12, it will return a sequence of month of formatted month '\ "\ be written as "\

Examples

## Only with month (%m)
create_month(4, 8)
#> [1] "04" "05" "06" "07" "08"
create_month("04", "08") 
#> [1] "04" "05" "06" "07" "08"
create_month("08", "04") 
#> [1] "04" "05" "06" "07" "08"

## With year and month (%Y-%m)

create_month("2010-03", "2014-07")
#>  [1] "2010-03" "2010-04" "2010-05" "2010-06" "2010-07" "2010-08" "2010-09"
#>  [8] "2010-10" "2010-11" "2010-12" "2011-01" "2011-02" "2011-03" "2011-04"
#> [15] "2011-05" "2011-06" "2011-07" "2011-08" "2011-09" "2011-10" "2011-11"
#> [22] "2011-12" "2012-01" "2012-02" "2012-03" "2012-04" "2012-05" "2012-06"
#> [29] "2012-07" "2012-08" "2012-09" "2012-10" "2012-11" "2012-12" "2013-01"
#> [36] "2013-02" "2013-03" "2013-04" "2013-05" "2013-06" "2013-07" "2013-08"
#> [43] "2013-09" "2013-10" "2013-11" "2013-12" "2014-01" "2014-02" "2014-03"
#> [50] "2014-04" "2014-05" "2014-06" "2014-07"
create_month("2014-07", "2010-03")
#>  [1] "2010-03" "2010-04" "2010-05" "2010-06" "2010-07" "2010-08" "2010-09"
#>  [8] "2010-10" "2010-11" "2010-12" "2011-01" "2011-02" "2011-03" "2011-04"
#> [15] "2011-05" "2011-06" "2011-07" "2011-08" "2011-09" "2011-10" "2011-11"
#> [22] "2011-12" "2012-01" "2012-02" "2012-03" "2012-04" "2012-05" "2012-06"
#> [29] "2012-07" "2012-08" "2012-09" "2012-10" "2012-11" "2012-12" "2013-01"
#> [36] "2013-02" "2013-03" "2013-04" "2013-05" "2013-06" "2013-07" "2013-08"
#> [43] "2013-09" "2013-10" "2013-11" "2013-12" "2014-01" "2014-02" "2014-03"
#> [50] "2014-04" "2014-05" "2014-06" "2014-07"
create_month("2010-3", "2014-07")
#>  [1] "2010-03" "2010-04" "2010-05" "2010-06" "2010-07" "2010-08" "2010-09"
#>  [8] "2010-10" "2010-11" "2010-12" "2011-01" "2011-02" "2011-03" "2011-04"
#> [15] "2011-05" "2011-06" "2011-07" "2011-08" "2011-09" "2011-10" "2011-11"
#> [22] "2011-12" "2012-01" "2012-02" "2012-03" "2012-04" "2012-05" "2012-06"
#> [29] "2012-07" "2012-08" "2012-09" "2012-10" "2012-11" "2012-12" "2013-01"
#> [36] "2013-02" "2013-03" "2013-04" "2013-05" "2013-06" "2013-07" "2013-08"
#> [43] "2013-09" "2013-10" "2013-11" "2013-12" "2014-01" "2014-02" "2014-03"
#> [50] "2014-04" "2014-05" "2014-06" "2014-07"
create_month("2010-3", "2014-7")
#>  [1] "2010-03" "2010-04" "2010-05" "2010-06" "2010-07" "2010-08" "2010-09"
#>  [8] "2010-10" "2010-11" "2010-12" "2011-01" "2011-02" "2011-03" "2011-04"
#> [15] "2011-05" "2011-06" "2011-07" "2011-08" "2011-09" "2011-10" "2011-11"
#> [22] "2011-12" "2012-01" "2012-02" "2012-03" "2012-04" "2012-05" "2012-06"
#> [29] "2012-07" "2012-08" "2012-09" "2012-10" "2012-11" "2012-12" "2013-01"
#> [36] "2013-02" "2013-03" "2013-04" "2013-05" "2013-06" "2013-07" "2013-08"
#> [43] "2013-09" "2013-10" "2013-11" "2013-12" "2014-01" "2014-02" "2014-03"
#> [50] "2014-04" "2014-05" "2014-06" "2014-07"

if (FALSE) create_month(4, 13)
if (FALSE) create_month("04", "13")
if (FALSE) create_month("2010-13", "2014-07")
if (FALSE) create_month("01", "2014-07")