Accept data.table as incidence input / or error
Closed this issue · 1 comments
TimTaylor commented
Please place an "x" in all the boxes that apply
- I have the most recent version of incidence2 and R
- I have found a bug
- I have a reproducible example
- I want to request a new feature
Need to produce an error or convert if data.table object is provided as input
library(data.table)
library(incidence2)
dat <- incidence2::covidregionaldataUK
incidence(dat, date, count = cases_new)
#> An incidence object: 490 x 2
#> date range: [2020-01-30] to [2021-06-02]
#> cases_new: 8379330
#> interval: 1 day
#>
#> date_index cases_new
#> <date> <dbl>
#> 1 2020-01-30 3
#> 2 2020-01-31 0
#> 3 2020-02-01 0
#> 4 2020-02-02 0
#> 5 2020-02-03 0
#> 6 2020-02-04 0
#> 7 2020-02-05 2
#> 8 2020-02-06 0
#> 9 2020-02-07 0
#> 10 2020-02-08 8
#> # … with 480 more rows
setDT(dat)
incidence(dat, date, count = cases_new)
#> Error in `[.data.table`(x, date_index): When i is a data.table (or character vector), the columns to join by must be specified using 'on=' argument (see ?data.table), by keying x (i.e. sorted, and, marked as sorted, see ?setkey), or by sharing column names between x and i (i.e., a natural join). Keyed joins might have further speed benefits on very large data due to x being sorted in RAM.
Created on 2021-08-23 by the reprex package (v2.0.1)