this_week {timeperiodsR}R Documentation

Start and end of week

Description

Defines first and last date in week

Usage

this_week(x = Sys.Date(), 
          part = getOption("timeperiodsR.parts"), 
		      week_start = 1)

Arguments

x

Date object

part

Part of period you need to receive, one of "all", "start", "end","sequence", "length". See details.

week_start

Start of week, default = 1 is Monday, 7 is Sunday

Details

You can get object of tpr class with all components or specify which component you need, use part for manage this option:

Value

Object of tpr class

Author(s)

Alexey Seleznev

See Also

For get next other periods see this_quarter(), this_month(), this_year()

Examples

## To get start, end and sequence of this weeks
thisweek <- this_week()

## Get this week with start on Sunday
thisweeksun <- this_week(week_start = 7)

## To get vector of date sequences 
this_week(part = "sequence")
this_week()$sequence
seq(thisweek)

## Get number of days of this 2 weeks
day_nums <- this_week(part = "length")
this_week()$length
length(thisweek)

[Package timeperiodsR version 0.7.3 Index]