[Stable]

Create or coerce using yearweek().

yearweek(x = NULL, ...)

Arguments

x

Other object.

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

scale_x_yearweek and others for ggplot2 scales

Other index functions: yearmonth(), yearquarter()

Examples

# coerce POSIXct/Dates to yearweek
x <- seq(as.Date("2016-01-01"), as.Date("2016-12-31"), by = "1 week")
yearweek(x)
#> Error in loadNamespace(x): there is no package called ‘vecvec’
yearweek(x, week_start = 7)
#> Error in loadNamespace(x): there is no package called ‘vecvec’

# parse characters
yearweek(c("2018 W01", "2018 Wk01", "2018 Week 1"))
#> Error in loadNamespace(x): there is no package called ‘vecvec’

# seq() and arithmetic
wk1 <- yearweek("2017 W50")
#> Error in loadNamespace(x): there is no package called ‘vecvec’
wk2 <- yearweek("2018 W12")
#> Error in loadNamespace(x): there is no package called ‘vecvec’
seq(from = wk1, to = wk2, by = 2)
#> Error: object 'wk1' not found
wk1 + 0:9
#> Error: object 'wk1' not found

# display formats
format(c(wk1, wk2), format = "%V/%Y")
#> Error: object 'wk1' not found

make_yearweek(year = 2021, week = 10:11)
#> Error in make_yearweek(year = 2021, week = 10:11): could not find function "make_yearweek"
make_yearweek(year = 2020:2021, week = 10:11)
#> Error in make_yearweek(year = 2020:2021, week = 10:11): could not find function "make_yearweek"

is_53weeks(2015:2016)
#> Error in is_53weeks(2015:2016): could not find function "is_53weeks"
is_53weeks(1969)
#> Error in is_53weeks(1969): could not find function "is_53weeks"
is_53weeks(1969, week_start = 7)
#> Error in is_53weeks(1969, week_start = 7): could not find function "is_53weeks"