Comments (4)
This is tricky as currently we transform the data to a better behaved (unit spacing between consecutive date groups) scale within the plotting function. The solution is to transform the data prior to making the class. It may actually be better to do this as the underlying representation is likely to be better for the user. Will start a new branch to explore.
from incidence2.
I think 3f1d2f4 will enable what I think your use case is with a little hacking (see below). I'm not sure we want to be any more flexible than this (i.e. allowing hacking if really needed):
library(outbreaks)
library(incidence2)
library(ggplot2)
res <- incidence(
covid19_england_nhscalls_2020,
date_index = date,
interval = "1 week"
)
res
#> An incidence2 object: 27 x 2
#> 253670 cases from 2020-W12 to 2020-W38
#> interval: 1 monday week
#> cumulative: FALSE
#>
#> date_index count
#> <yrwk> <int>
#> 1 2020-W12 12987
#> 2 2020-W13 18263
#> 3 2020-W14 14389
#> 4 2020-W15 11486
#> 5 2020-W16 10058
#> 6 2020-W17 10562
#> 7 2020-W18 11367
#> 8 2020-W19 10846
#> 9 2020-W20 10396
#> 10 2020-W21 9816
#> # … with 17 more rows
xint <- (as.integer(res$date_index[19]) + as.integer(res$date_index[20])) / 2
plot(res) + geom_vline(xintercept = xint)
Created on 2021-03-02 by the reprex package (v1.0.0)
from incidence2.
Looks perfect to me! Agreed re the desired level of flexibility.
from incidence2.
closed with 3f1d2f4
from incidence2.
Related Issues (20)
- Should we only provide getters for the variable names (not values)?
- Should a `find_peaks()` like function be in incidence HOT 1
- Restore some of the header information for incidence2 objects HOT 1
- Add minimal `new_incidence()` constructor
- Should `complete_dates()` use a different default `by` argument for POSIXct dates? HOT 7
- Consider warning when incidence objects are created with POSIXct dates HOT 1
- Error: object 'date_onset' not found HOT 1
- Error: show_cases dont work HOT 9
- reinstate `day` interval HOT 1
- Document `day` interval in vignettes.
- `plot.incidence2()` fails with `grates_period` dates HOT 3
- Make makefile more usable by others
- Ensure data.table uses 2 threads max in docs and examples
- NA values in observations cause a value of NA to be returned HOT 10
- Document how to handle grouped line list columns HOT 4
- Allow user to suppress NA warning in count variables
- vignette documentation on building upon incidence2 HOT 2
- Fix formatting of old news entries HOT 1
- Rework the devel news entry HOT 1
- 2.3.0 release TODO
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from incidence2.