reconhub / incidence

☣:chart_with_upwards_trend::chart_with_downwards_trend:☣ Compute and visualise incidence
https://reconhub.github.io/incidence
Other
58 stars 13 forks source link

Prioritise standard #108

Closed zkamvar closed 5 years ago

zkamvar commented 5 years ago

This will fix #87

library("incidence")
d <- Sys.Date() + sample(-3:10, 10, replace = TRUE)
Sys.Date() - 10
#> [1] "2019-02-23"

standard specified, no warning

incidence(d, interval = "week", first_date = Sys.Date() - 10, standard = TRUE)
#> <incidence object>
#> [10 cases from days 2019-02-18 to 2019-03-11]
#> [10 cases from ISO weeks 2019-W08 to 2019-W11]
#> 
#> $counts: matrix with 4 rows and 1 columns
#> $n: 10 cases in total
#> $dates: 4 dates marking the left-side of bins
#> $interval: 1 week
#> $timespan: 22 days
#> $cumulative: FALSE

warning issued if standard not specified

incidence(d, interval = "week", first_date = Sys.Date() - 10)
#> Warning in incidence.Date(d, interval = "week", first_date = Sys.Date() - : 
#> 
#> As of incidence version 1.6.0, the default behavior has been modified so that `first_date` no longer overrides `standard`. If you want to use Sys.Date() - 10 as the precise `first_date`, set `standard = FALSE`.
#> 
#> To remove this warning in the future,  explicitly set the `standard` argument OR use `options(incidence.warn.first_date = FALSE)`
#> <incidence object>
#> [10 cases from days 2019-02-18 to 2019-03-11]
#> [10 cases from ISO weeks 2019-W08 to 2019-W11]
#> 
#> $counts: matrix with 4 rows and 1 columns
#> $n: 10 cases in total
#> $dates: 4 dates marking the left-side of bins
#> $interval: 1 week
#> $timespan: 22 days
#> $cumulative: FALSE

second instance: no warning issued

incidence(d, interval = "week", first_date = Sys.Date() - 10)
#> <incidence object>
#> [10 cases from days 2019-02-18 to 2019-03-11]
#> [10 cases from ISO weeks 2019-W08 to 2019-W11]
#> 
#> $counts: matrix with 4 rows and 1 columns
#> $n: 10 cases in total
#> $dates: 4 dates marking the left-side of bins
#> $interval: 1 week
#> $timespan: 22 days
#> $cumulative: FALSE

Created on 2019-03-05 by the reprex package (v0.2.1)