week_start: Get and set the global week_start variable

Description Usage Arguments Value See Also Examples

Description

This is a convenience wrapper around options() and getOption(), which allows users to input both numeric and character week start values

Usage

1
2
3

Arguments

x

a character or integer specifying the day of the week for conversion between dates and weeks.

w

if NULL, the global option "aweek.week_start" is returned. If w is an aweek object, then the "week_start" attribute is returned.

Value

for set_week_start, the old value of week_start is returned, invisibly. For get_week_start, the current value of week_start is returned.

See Also

change_week_start() for changing the week_start attribute of an aweek object, date2week(), week2date()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# get the current definition of the week start
get_week_start() # defaults to Monday (1)
getOption("aweek.week_start", 1L) # identical to above

# set the week start
mon <- set_week_start("Sunday") # set week start to Sunday (7)
get_week_start()
print(set_week_start(mon)) # reset the default
get_week_start()

# Get the week_start of a specific aweek object.
w <- date2week("2019-05-04", week_start = "Sunday")
get_week_start(w)

reconhub/aweek documentation built on March 25, 2021, 12:03 a.m.