next_n_weeks: Start and end of next n weeks

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/next_n_weeks.R

Description

Defines first and last date in next period

Usage

1
2
3
4
5
next_n_weeks(x = Sys.Date(), 
             n = 1, 
             part = getOption("timeperiodsR.parts"), 
			       week_start = 1, 
			       include_current = F)

Arguments

x

Date object

n

Number of periods for offset

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

include_current

If TRUE incliding current period in sequence

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 last_n_months(), last_n_days(), last_n_years(), last_n_quarters()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## To get start, end and sequence of next 2 weeks, 
## exclude current week
next2weeks <- next_n_weeks(n = 2)

## include current week
next2weeks_2 <- next_n_weeks(n = 2, include_current = TRUE)

## Get next 2 week with start on Sunday
nextWeek <- next_n_weeks(n = 2, week_start = 7)

## To get vector of date sequences 
next_n_weeks(n = 2, part = "sequence")
next_n_weeks(n = 2)$sequence
seq(next2weeks)

## Get number of days of next 2 weeks
day_nums <- next_n_weeks(part = "length")
next_n_weeks()$length
length(next2weeks)

timeperiodsR documentation built on April 3, 2020, 9:10 a.m.