Skip to contents

[Experimental]

tbl_now_from_data_table() converts a data.table into a tbl_now (requires explicit event_date / report_date columns). tbl_now_to_data_table() strips the tbl_now class and returns a data.table keeping every column; any lazy temporal effects are materialised first (see compute_temporal_effects()) so their columns are present.

Usage

tbl_now_from_data_table(data, event_date, report_date, ..., verbose = TRUE)

tbl_now_to_data_table(x, ..., verbose = TRUE)

Arguments

data

A data.table.

event_date, report_date

The event- and report-date columns, as tidy-select expressions: a bare column name or a string both work.

...

Forwarded to as_tbl_now() (from) or data.table::as.data.table() (to).

verbose

Logical. Print the choices that were made.

x

A tbl_now object.

Value

A tbl_now (from) or a data.table (to).

See also

as.data.table(), the data.table method that calls this; as_tibble() and as_tsibble() for the other exits from the class; tbl_now() to build one from the result. as_tbl_now() for the generic that dispatches to the *_from_*() side; run_nowcast(), which does the conversion for you when you fit through an engine(). The One dataset, many nowcasts article fits the same data with every supported package.

Examples

data(denguedat)
dt <- data.table::as.data.table(denguedat)
nowobj <- tbl_now_from_data_table(dt,
  event_date = "onset_week",
  report_date = "report_week", verbose = FALSE
)