MyNixOS website logo
Description

Definition of Date and Time Dimension Tables.

In Multidimensional Systems the When dimension allows us to express when the analysed facts have occurred. The purpose of this package is to provide support for implementing this dimension in the form of date and time tables for Relational On-Line Analytical Processing star database systems.

when when website

R-CMD-check Codecov testcoverage

The When Dimension[^1] plays a fundamental role in Multidimensional Systems, it allows us to express when the analysed focus of attention have occurred.

The purpose of the when package is to assist in the implementation of the When Dimension. In particular, it supports the generation of tables with the granularity needed (second, minute, hour, date, week, month, quarter, semester or year) in Multidimensional Systems implemented on a ROLAP (Relational On-Line Analytical Processing) star database. It relies on the functions offered by the lubridate package to obtain the components from the date and time.

Installation

You can install the released version of when from CRAN with:

install.packages("when")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("josesamos/when")

Example

To obtain a table with dates we indicate the start and end date. Alternatively we can indicate the set of dates to consider. We can select the level of detail, the attributes to include or the language of the literals for day and month names. In the following example we indicate the language because it is different from the one we have in the computer’s operating system.

library(when)

date <-
  when(
    locale = Sys.setlocale("LC_TIME", "English"),
    start = lubridate::today(),
    end = lubridate::today() + lubridate::years(5)
  ) |>
  generate_table() |>
  get_table()

The first and last rows of the obtained result are shown below.

pander::pandoc.table(rbind(head(date, 5), tail(date, 5)),
                     split.table = Inf)
iddatemonth_dayweek_dayday_nameday_num_nameyear_weekweekyear_monthmonthmonth_namemonth_num_nameyear
12024-01-08081Monday1-Monday2024-02022024-0101January01-January2024
22024-01-09092Tuesday2-Tuesday2024-02022024-0101January01-January2024
32024-01-10103Wednesday3-Wednesday2024-02022024-0101January01-January2024
42024-01-11114Thursday4-Thursday2024-02022024-0101January01-January2024
52024-01-12125Friday5-Friday2024-02022024-0101January01-January2024
18242029-01-04044Thursday4-Thursday2029-01012029-0101January01-January2029
18252029-01-05055Friday5-Friday2029-01012029-0101January01-January2029
18262029-01-06066Saturday6-Saturday2029-01012029-0101January01-January2029
18272029-01-07077Sunday7-Sunday2029-01012029-0101January01-January2029
18282029-01-08081Monday1-Monday2029-02022029-0101January01-January2029

If we want a table with time, we indicate the type using a parameter. By default we get all the seconds of a day but we can also configure a different period or level of detail.

time <-
  when(type = 'time', start = "08:00", end = "17:00") |>
  generate_table() |>
  get_table()

The start and end of the result table is shown below.

pander::pandoc.table(rbind(head(time, 5), tail(time, 5)),
                     split.table = Inf)
idtimehourminutesecondday_part
108:00:00080000Morning
208:00:01080001Morning
308:00:02080002Morning
408:00:03080003Morning
508:00:04080004Morning
3239716:59:56165956Afternoon
3239816:59:57165957Afternoon
3239916:59:58165958Afternoon
3240016:59:59165959Afternoon
3240117:00:00170000Evening

The day_part attribute is predefined in English. Literals or associated hours can be changed using a configuration function.

In addition to obtaining them as tibble, we can export the tables to files in csv or xlsx format. They can also be exported directly to any Relational DBMS.

[^1]: Often called “Time Dimension” or “Date Dimension”.

Metadata

Version

1.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD 13
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd13
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows