Learn R Programming

tsibble (version 0.9.1)

yearweek: Represent year-week (ISO) starting on Monday

Description

stable

Create or coerce using yearweek().

Usage

yearweek(x)

is_yearweek(x)

is_53weeks(year)

Arguments

x

Other object.

year

A vector of years.

Value

year-week (yearweek) objects.

TRUE/FALSE if the year has 53 ISO weeks.

Display

Use format() to display yearweek, yearmonth, and yearquarter objects in required formats. Please see strptime() details for supported conversion specifications.

See Also

Other index functions: yearmonth(), yearquarter()

Examples

Run this code
# NOT RUN {
# coerce POSIXct/Dates to yearweek
x <- seq(as.Date("2016-01-01"), as.Date("2016-12-31"), by = "1 week")
yearweek(x)

# parse characters
yearweek(c("2018 W01", "2018 Wk01", "2018 Week 1"))

# creat an empty yearweek container
yearweek()

# seq() and arithmetic
wk1 <- yearweek("2017 W50")
wk2 <- yearweek("2018 W12")
seq(from = wk1, to = wk2, by = 2)
wk1 + 0:9

# display formats
format(c(wk1, wk2), format = "%V/%Y")

# units since 1969-12-29
as.double(yearweek("1969 W41") + 0:24)
is_53weeks(2015:2016)
# }

Run the code above in your browser using DataLab