Skip to contents

Checks that a data frame has the required columns and structure for use with get_ncast and get_fcast. Returns a typed accidda_data object that downstream functions can accept without repeating validation.

Usage

check_data(df)

Arguments

df

A data frame (or tibble) with at least: target_end_date (Date), observation (numeric), location (character), and target (character). An optional as_of (Date) column enables nowcasting via get_ncast.

Value

An accidda_data object (a list) with:

data

The validated data frame with coerced date types.

location

Single location identifier.

target

Single target identifier.

window

Named vector with from and to dates.

history

Logical. TRUE if revision history (as_of) is present.

Examples

if (FALSE) { # \dontrun{
# From get_data
df <- get_data("covid", "ny") |> check_data()

# User-provided data
my_df <- read.csv("my_data.csv") |> check_data()

# Then into the pipeline
df |> get_fcast(eval_start_date = "2025-01-01")
} # }