When the dimension is defined as a date type, using this function we can select the week level and its attributes to include in it: week and year_week.
Usage
select_week_level(td, include_all, exclude_all, week, year_week)
# S3 method for when
select_week_level(
td,
include_all = FALSE,
exclude_all = FALSE,
week = NULL,
year_week = 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.
- week
A boolean, include the week number.
- year_week
A boolean, include the year-week combination.
Details
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.
For the first and last days of the year, the year associated with the week may be different from the year of the date, depending on the date type selected.
The week number associated with each date depends on the type of date dimension selected: standard ('date'), ISO 8601 ('iso') or epidemiological ('epi').
The standard week numbers blocks of 7 days beginning on January 1. The last week of the year can be less than 7 days long.
The ISO 8601 week numbers blocks of 7 days from Monday to Sunday. The first and last week of the year can contain days from the previous or next year.
The epidemiological week is like ISO 8601 only that it considers that the week begins on Sunday.
See also
Other dimension definition:
define_characteristics()
,
define_instances()
,
get_attribute_definition_function()
,
get_day_part()
,
get_week_date_range()
,
select_date_levels()
,
select_day_level()
,
select_month_level()
,
select_quarter_level()
,
select_semester_level()
,
select_time_level()
,
select_year_level()
,
set_attribute_definition_function()
,
set_day_part()
,
when()
Examples
td <- when() |>
select_week_level(year_week = FALSE)