`year-week.Rd`

yearweek(x) is_yearweek(x) is_53weeks(year) # S3 method for yearweek year(x)

x | Other object. |
---|---|

year | A vector of years. |

year-week (`yearweek`

) objects.

`TRUE`

/`FALSE`

if the year has 53 ISO weeks.

Other index functions:
`yearmonth()`

,
`yearquarter()`

# coerce POSIXct/Dates to yearweek x <- seq(as.Date("2016-01-01"), as.Date("2016-12-31"), by = "1 week") yearweek(x)#> <yearweek[53]> #> [1] "2015 W53" "2016 W01" "2016 W02" "2016 W03" "2016 W04" "2016 W05" #> [7] "2016 W06" "2016 W07" "2016 W08" "2016 W09" "2016 W10" "2016 W11" #> [13] "2016 W12" "2016 W13" "2016 W14" "2016 W15" "2016 W16" "2016 W17" #> [19] "2016 W18" "2016 W19" "2016 W20" "2016 W21" "2016 W22" "2016 W23" #> [25] "2016 W24" "2016 W25" "2016 W26" "2016 W27" "2016 W28" "2016 W29" #> [31] "2016 W30" "2016 W31" "2016 W32" "2016 W33" "2016 W34" "2016 W35" #> [37] "2016 W36" "2016 W37" "2016 W38" "2016 W39" "2016 W40" "2016 W41" #> [43] "2016 W42" "2016 W43" "2016 W44" "2016 W45" "2016 W46" "2016 W47" #> [49] "2016 W48" "2016 W49" "2016 W50" "2016 W51" "2016 W52"#> <yearweek[3]> #> [1] "2018 W01" "2018 W01" "2018 W01"# creat an empty yearweek container yearweek()#> <yearweek[0]># seq() and arithmetic wk1 <- yearweek("2017 W50") wk2 <- yearweek("2018 W12") seq(from = wk1, to = wk2, by = 2)#> <yearweek[8]> #> [1] "2017 W50" "2017 W52" "2018 W02" "2018 W04" "2018 W06" "2018 W08" "2018 W10" #> [8] "2018 W12"wk1 + 0:9#> <yearweek[10]> #> [1] "2017 W50" "2017 W51" "2017 W52" "2018 W01" "2018 W02" "2018 W03" #> [7] "2018 W04" "2018 W05" "2018 W06" "2018 W07"#> [1] "50/2017" "12/2018"#> [1] -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 #> [20] 7 8 9 10 11 12is_53weeks(2015:2016)#> [1] TRUE FALSE