pkgdown/extra.css

Skip to contents

[Experimental]

Convert a supported object into a tbl_now. For a plain data.frame / data.table (or an existing tbl_now) you supply the event_date and report_date columns yourself. For objects produced by other packages the conversion is delegated to the matching tbl_now_from_*() converter, which already knows how to map that format – so those methods do not take event_date / report_date.

Usage

as_tbl_now(object, ...)

# S3 method for class 'tbl_now'
as_tbl_now(object, event_date, report_date, ...)

# S3 method for class 'data.frame'
as_tbl_now(object, event_date, report_date, ...)

# S3 method for class 'enw_preprocess_data'
as_tbl_now(object, ...)

# S3 method for class 'reporting_triangle'
as_tbl_now(object, ...)

# S3 method for class 'epidist_linelist_data'
as_tbl_now(object, ...)

# S3 method for class 'epidist_aggregate_data'
as_tbl_now(object, ...)

# S3 method for class 'tbl_ts'
as_tbl_now(object, report_date, event_date = NULL, ...)

# S3 method for class 'data.table'
as_tbl_now(object, event_date, report_date, ...)

Arguments

object

An object to convert to a tbl_now.

...

Additional arguments forwarded to the relevant tbl_now_from_*() converter (and therefore to tbl_now()).

event_date, report_date

For data.frame / data.table / tbl_ts (and tbl_now) inputs, the tidy-select event- and report-date columns. They are not arguments of the package-conversion methods (epinowcast, baselinenowcast, epidist), which carry their own date mapping.

Value

A tbl_now object.

Details

Package-specific inputs forward to a dedicated converter. See that converter for the extra arguments it accepts (e.g. strata, max_delay, format, delays_unit, ...), for which columns are carried over, and for the transformation notes / round-trip caveats in its Round-trip section:

Anything passed through ... is forwarded to the underlying converter (and on to tbl_now()), so options such as event_units, now or verbose can be supplied here too.

Examples

# Convert a data.frame to tbl_now
data(denguedat)
as_tbl_now(denguedat, event_date = "onset_week", report_date = "report_week")
#>  Identified data as <linelist-data> where each observation is a test.
#> # A tibble:  52,987 × 6
#> # Data type: "linelist"
#> # Frequency: Event: `weeks` | Report: `weeks`
#>    onset_week   report_week   gender .event_num .report_num .delay
#>    <date>       <date>        <chr>       <dbl>       <dbl>  <dbl>
#>    [event_date] [report_date] [...]       [...]       [...]  [...]
#>  1 1990-01-01   1990-01-01    Male            0           0      0
#>  2 1990-01-01   1990-01-01    Female          0           0      0
#>  3 1990-01-01   1990-01-01    Female          0           0      0
#>  4 1990-01-01   1990-01-08    Female          0           1      1
#>  5 1990-01-01   1990-01-08    Male            0           1      1
#>  6 1990-01-01   1990-01-15    Female          0           2      2
#>  7 1990-01-01   1990-01-15    Female          0           2      2
#>  8 1990-01-01   1990-01-15    Female          0           2      2
#>  9 1990-01-01   1990-01-22    Female          0           3      3
#> 10 1990-01-01   1990-01-08    Female          0           1      1
#> # ────────────────────────────────────────────────────────────────────────────────
#> # Now: 2010-12-20 | Event date: "onset_week" | Report date: "report_week"
#> # ────────────────────────────────────────────────────────────────────────────────
#> # ℹ 52,977 more rows