Retrieve dates from an incidence object
get_dates(x, ...) # S3 method for default get_dates(x, ...) # S3 method for incidence get_dates(x, position = "left", count_days = FALSE, ...)
x | an incidence object |
---|---|
... | Unused |
position | One of "left", "center", "middle", or "right" specifying what side of the bin the date should be drawn from. |
count_days | If |
a vector of dates or numerics
set.seed(999) dat <- as.Date(Sys.Date()) + sample(-3:50, 100, replace = TRUE) x <- incidence(dat, interval = "month") get_dates(x)#> [1] "2020-07-01" "2020-08-01" "2020-09-01"get_dates(x, position = "middle")#> [1] "2020-07-16" "2020-08-16" "2020-09-16"set.seed(999) dat <- as.Date(Sys.Date()) + sample(-3:50, 100, replace = TRUE) x <- incidence(dat, interval = "month") get_dates(x)#> [1] "2020-07-01" "2020-08-01" "2020-09-01"get_dates(x, "center")#> [1] "2020-07-16" "2020-08-16" "2020-09-16"get_dates(x, "right")#> [1] "2020-08-01" "2020-09-01" "2020-10-01"# Return dates by number of days from the first date get_dates(x, count_days = TRUE)#> [1] 0 31 62#> [1] 0 1 2 3 4 5 6 7 8 9 10