Skip to contents

When the dimension is defined as a date type, using this function we can select the month level and its attributes to include in it. We can also obtain the combination of the year with the month number.

Usage

select_month_level(
  td,
  include_all,
  exclude_all,
  month,
  year_month,
  month_name,
  month_num_name,
  month_abbr,
  month_num_abbr
)

# S3 method for when
select_month_level(
  td,
  include_all = FALSE,
  exclude_all = FALSE,
  month = NULL,
  year_month = NULL,
  month_name = NULL,
  month_num_name = NULL,
  month_abbr = NULL,
  month_num_abbr = NULL
)

Arguments

td

A when object.

include_all

A boolean, include all fields of the level.

exclude_all

A boolean, exclude all fields of the level.

month

A boolean, include the month number.

year_month

A boolean, include the year-month combination.

month_name

A boolean, include the month name.

month_num_name

A boolean, include the month number and name.

month_abbr

A boolean, include the month name abbreviated version.

month_num_abbr

A boolean, include the month number and name abbreviated version.

Value

A when object.

Details

For the month we have the month number in the year, its name and the abbreviation of the name. So that the order of the names corresponds to the alphabetical order, the combination of month number and name and/or abbreviation is included.

The include_all and exclude_all parameters allow us to include or exclude all attributes, and then specifically exclude or include the ones we need.

Examples


td <- when() |>
  select_month_level(month_abbr = FALSE,
                      month_num_abbr = FALSE)