Skip to content

Latest commit

 

History

History
49 lines (45 loc) · 1.72 KB

aweek.md

File metadata and controls

49 lines (45 loc) · 1.72 KB
library("aweek")

(w <- get_aweek(week = 10, year = 2020, day = 1:7))
#> <aweek start: Monday>
#> [1] "2020-W10-1" "2020-W10-2" "2020-W10-3" "2020-W10-4" "2020-W10-5"
#> [6] "2020-W10-6" "2020-W10-7"
trunc(w)
#> <aweek start: Monday>
#> [1] "2020-W10" "2020-W10" "2020-W10" "2020-W10" "2020-W10" "2020-W10" "2020-W10"
week2date(w)
#> [1] "2020-03-02" "2020-03-03" "2020-03-04" "2020-03-05" "2020-03-06"
#> [6] "2020-03-07" "2020-03-08"
as.Date(w)
#> [1] "2020-03-02" "2020-03-03" "2020-03-04" "2020-03-05" "2020-03-06"
#> [6] "2020-03-07" "2020-03-08"
date2week(c("2020-03-03", "2020-03-07"))
#> <aweek start: Monday>
#> [1] "2020-W10-2" "2020-W10-6"
as.aweek(as.Date("2020-03-02") + 0:6)
#> <aweek start: Monday>
#> [1] "2020-W10-1" "2020-W10-2" "2020-W10-3" "2020-W10-4" "2020-W10-5"
#> [6] "2020-W10-6" "2020-W10-7"

set_week_start("Saturday")

(w <- get_aweek(week = 10, year = 2020, day = 1:7))
#> <aweek start: Saturday>
#> [1] "2020-W10-1" "2020-W10-2" "2020-W10-3" "2020-W10-4" "2020-W10-5"
#> [6] "2020-W10-6" "2020-W10-7"
trunc(w)
#> <aweek start: Saturday>
#> [1] "2020-W10" "2020-W10" "2020-W10" "2020-W10" "2020-W10" "2020-W10" "2020-W10"
week2date(w)
#> [1] "2020-03-07" "2020-03-08" "2020-03-09" "2020-03-10" "2020-03-11"
#> [6] "2020-03-12" "2020-03-13"
as.Date(w)
#> [1] "2020-03-07" "2020-03-08" "2020-03-09" "2020-03-10" "2020-03-11"
#> [6] "2020-03-12" "2020-03-13"
date2week(c("2020-03-03", "2020-03-07"))
#> <aweek start: Saturday>
#> [1] "2020-W09-4" "2020-W10-1"
as.aweek(as.Date("2020-03-02") + 0:6)
#> <aweek start: Saturday>
#> [1] "2020-W09-3" "2020-W09-4" "2020-W09-5" "2020-W09-6" "2020-W09-7"
#> [6] "2020-W10-1" "2020-W10-2"

Created on 2020-03-03 by the reprex package (v0.3.0)