calendar {timeplyr}R Documentation

Create a table of common time units from a date or datetime sequence.

Description

Create a table of common time units from a date or datetime sequence.

Usage

calendar(
  x,
  label = TRUE,
  week_start = getOption("lubridate.week.start", 1),
  fiscal_start = getOption("lubridate.fiscal.start", 1),
  name = "time"
)

add_calendar(
  data,
  time = NULL,
  label = TRUE,
  week_start = getOption("lubridate.week.start", 1),
  fiscal_start = getOption("lubridate.fiscal.start", 1)
)

Arguments

x

date or datetime vector.

label

Logical. Should labelled (ordered factor) versions of week day and month be returned? Default is TRUE.

week_start

day on which week starts following ISO conventions - 1 means Monday, 7 means Sunday (default). When label = TRUE, this will be the first level of the returned factor. You can set lubridate.week.start option to control this parameter globally.

fiscal_start

Numeric indicating the starting month of a fiscal year.

name

Name of date/datetime column.

data

A data frame.

time

Time variable.

Value

An object of class tibble.

Examples

library(timeplyr)
library(lubridate)

# Create a calendar for the current year
from <- floor_date(today(), unit = "year")
to <- ceiling_date(today(), unit = "year", change_on_boundary = TRUE) - days(1)

my_seq <- time_seq(from, to, time_by = "day")
calendar(my_seq)


[Package timeplyr version 0.5.0 Index]