Skip to contents

With this function we can define the characteristics of the dimension that do not depend on the levels it includes, such as the name, type, location or the day the week begins. It also allows us to define whether the table includes a surrogate key.

Usage

define_characteristics(
  td,
  name,
  surrogate_key,
  type,
  locale,
  week_starts_monday
)

# S3 method for when
define_characteristics(
  td,
  name = NULL,
  surrogate_key = NULL,
  type = NULL,
  locale = NULL,
  week_starts_monday = NULL
)

Arguments

td

A when object.

name

A string, table name.

surrogate_key

A boolean, include a surrogate key in the dimension table.

type

A string, type of calendar (NULL, 'iso', 'epi' or 'time').

locale

A locale, to use for day and month names.

week_starts_monday

A boolean.

Value

A when object.

Details

The week_starts_monday parameter only affects the numbering of days, not weeks.

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.

Examples


td <- when() |>
  define_characteristics(name = 'time', type = 'time')