diff --git a/man/cases_deaths_subset.Rd b/man/cases_deaths_subset.Rd new file mode 100644 index 00000000..b74e245a --- /dev/null +++ b/man/cases_deaths_subset.Rd @@ -0,0 +1,79 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reexports-epidatasets.R +\docType{data} +\name{cases_deaths_subset} +\alias{cases_deaths_subset} +\title{Subset of JHU daily state COVID-19 cases and deaths from 6 states} +\format{ +An object of class \code{epi_df} (inherits from \code{tbl_df}, \code{tbl}, \code{data.frame}) with 4026 rows and 6 columns. +} +\source{ +This object contains a modified part of the +\href{https://github.com/CSSEGISandData/COVID-19}{COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University} +as \href{https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/jhu-csse.html}{republished in the COVIDcast Epidata API}. +This data set is licensed under the terms of the +\href{https://creativecommons.org/licenses/by/4.0/}{Creative Commons Attribution 4.0 International license} +by the Johns Hopkins University on behalf of its Center for Systems Science +in Engineering. Copyright Johns Hopkins University 2020. + +Modifications: +\itemize{ +\item \href{https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/jhu-csse.html}{From the COVIDcast Epidata API}: +The case signal is taken directly from the JHU CSSE +\href{https://github.com/CSSEGISandData/COVID-19}{COVID-19 GitHub repository}. +The rate signals were computed by Delphi using Census population data. +The 7-day average signals were computed by Delphi by calculating moving +averages of the preceding 7 days, so the signal for June 7 is the +average of the underlying data for June 1 through 7, inclusive. +\item Furthermore, the data has been limited to a very small number of rows, the +signal names slightly altered, and formatted into an \code{epi_df}. +} +} +\usage{ +cases_deaths_subset +} +\description{ +This data source of confirmed COVID-19 cases and deaths is based on reports +made available by the Center for Systems Science and Engineering at Johns +Hopkins University. This example data is a snapshot as of March 20, 2024, and +ranges from March 1, 2020 to December 31, 2021. It is limited to California, +Florida, Texas, New York, Georgia, and Pennsylvania. + +It is used in the {epiprocess} growth rate and \code{epi_slide} vignettes. +} +\section{Data dictionary}{ + + +The data has columns: +\describe{ +\item{geo_value}{the geographic value associated with each row +of measurements.} +\item{time_value}{the time value associated with each row of measurements.} +\item{case_rate_7d_av}{7-day average signal of number of new +confirmed COVID-19 cases per 100,000 population, daily} +\item{death_rate_7d_av}{7-day average signal of number of new confirmed +deaths due to COVID-19 per 100,000 population, daily} +\item{cases}{Number of new confirmed COVID-19 cases, daily} +\item{cases_7d_av}{7-day average signal of number of new confirmed +COVID-19 cases, daily} +} + +} + +\examples{ +# Since this is a re-exported dataset, it cannot be loaded using +# the `data()` function. `data()` looks for a file of the same name +# in the `data/` directory, which doesn't exist in this package. +# works +epipredict::cases_deaths_subset + +# works +library(epipredict) +cases_deaths_subset + +# fails +\dontrun{ +data(cases_deaths_subset, package = "epipredict") +} +} +\keyword{datasets} diff --git a/tests/testthat/_snaps/arg_is_.md b/tests/testthat/_snaps/arg_is_.md new file mode 100644 index 00000000..f05ca780 --- /dev/null +++ b/tests/testthat/_snaps/arg_is_.md @@ -0,0 +1,384 @@ +# logical + + Code + arg_is_lgl(l, ll, n) + Condition + Error: + ! `n` must be of type . + +--- + + Code + arg_is_lgl(x) + Condition + Error: + ! `x` must be of type . + +--- + + Code + arg_is_lgl(l, ll, nn) + Condition + Error: + ! `nn` must be of type . + +# scalar + + Code + arg_is_scalar(x, y, n) + Condition + Error: + ! `n` must be a scalar. + +--- + + Code + arg_is_scalar(x, y, nn) + Condition + Error: + ! `nn` must be a scalar. + +--- + + Code + arg_is_scalar(v, nn) + Condition + Error: + ! `v` must be a scalar. + +--- + + Code + arg_is_scalar(v, nn, allow_na = TRUE) + Condition + Error: + ! `v` must be a scalar. + +--- + + Code + arg_is_scalar(v, n, allow_null = TRUE) + Condition + Error: + ! `v` must be a scalar. + +--- + + Code + arg_is_scalar(nnn, allow_na = TRUE) + Condition + Error: + ! `nnn` must be a scalar. + +# numeric + + Code + arg_is_numeric(a) + Condition + Error: + ! `a` must be of type . + +--- + + Code + arg_is_numeric(i, j, n) + Condition + Error: + ! `n` must be of type . + +--- + + Code + arg_is_numeric(i, nn) + Condition + Error: + ! `nn` must be of type . + +# positive + + Code + arg_is_pos(a) + Condition + Error: + ! `a` must be a strictly positive number. + +--- + + Code + arg_is_pos(i, k) + Condition + Error: + ! `k` must be strictly positive numbers. + +--- + + Code + arg_is_pos(i, j, n) + Condition + Error: + ! `n` must be strictly positive numbers. + +--- + + Code + arg_is_pos(i, nn) + Condition + Error: + ! `nn` must be a strictly positive number. + +--- + + Code + arg_is_pos(a = 0:10) + Condition + Error: + ! `0:10` must be strictly positive numbers. + +# nonneg + + Code + arg_is_nonneg(a) + Condition + Error: + ! `a` must be a non-negative number. + +--- + + Code + arg_is_nonneg(i, k) + Condition + Error: + ! `k` must be non-negative numbers. + +--- + + Code + arg_is_nonneg(i, j, n) + Condition + Error: + ! `n` must be non-negative numbers. + +--- + + Code + arg_is_nonneg(i, nn) + Condition + Error: + ! `nn` must be a non-negative number. + +# nonneg-int + + Code + arg_is_nonneg_int(a) + Condition + Error: + ! `a` must be a non-negative integer. + +--- + + Code + arg_is_nonneg_int(d) + Condition + Error: + ! `d` must be a non-negative integer. + +--- + + Code + arg_is_nonneg_int(i, k) + Condition + Error: + ! `k` must be non-negative integers. + +--- + + Code + arg_is_nonneg_int(i, j, n) + Condition + Error: + ! `n` must be non-negative integers. + +--- + + Code + arg_is_nonneg_int(i, nn) + Condition + Error: + ! `nn` must be a non-negative integer. + +# date + + Code + arg_is_date(d, dd, n) + Condition + Error: + ! `n` must be dates. + +--- + + Code + arg_is_date(d, dd, nn) + Condition + Error: + ! `nn` must be a date. + +--- + + Code + arg_is_date(a) + Condition + Error: + ! `a` must be a date. + +--- + + Code + arg_is_date(v) + Condition + Error: + ! `v` must be dates. + +--- + + Code + arg_is_date(ll) + Condition + Error: + ! `ll` must be dates. + +# probabilities + + Code + arg_is_probabilities(a) + Condition + Error: + ! `a` must lie in [0, 1]. + +--- + + Code + arg_is_probabilities(d) + Condition + Error: + ! `d` must lie in [0, 1]. + +--- + + Code + arg_is_probabilities(i, 1.1) + Condition + Error: + ! `1.1` must lie in [0, 1]. + +--- + + Code + arg_is_probabilities(c(0.4, 0.8), n) + Condition + Error: + ! `n` must lie in [0, 1]. + +--- + + Code + arg_is_probabilities(c(0.4, 0.8), nn) + Condition + Error: + ! `nn` must lie in [0, 1]. + +# chr + + Code + arg_is_chr(a, b, n) + Condition + Error: + ! `n` must be of type . + +--- + + Code + arg_is_chr(a, b, nn) + Condition + Error: + ! `nn` must be of type . + +--- + + Code + arg_is_chr(d) + Condition + Error: + ! `d` must be of type . + +--- + + Code + arg_is_chr(v) + Condition + Error: + ! `v` must be of type . + +--- + + Code + arg_is_chr(ll) + Condition + Error: + ! `ll` must be of type . + +--- + + Code + arg_is_chr(z) + Condition + Error: + ! `z` must be of type . + +# function + + Code + arg_is_function(c(a, b)) + Condition + Error: + ! `c(a, b)` must be of type . + +--- + + Code + arg_is_function(c(f, g)) + Condition + Error: + ! `c(f, g)` must be of type . + +--- + + Code + arg_is_function(f) + Condition + Error: + ! `f` must be of type . + +# coerce scalar to date + + Code + arg_to_date("12345") + Condition + Error in `arg_to_date()`: + ! `x` must be a date. + +--- + + Code + arg_to_date(c("12345", "12345")) + Condition + Error in `arg_to_date()`: + ! `x` must be a scalar. + +# simple surface step test + + Code + epi_recipe(cases_deaths_subset) %>% step_epi_lag(death_rate, lag = "hello") + Condition + Error in `step_epi_lag()`: + ! `lag` must be a non-negative integer. + diff --git a/tests/testthat/_snaps/snapshots.md b/tests/testthat/_snaps/snapshots.md index 9ce6502d..513964d9 100644 --- a/tests/testthat/_snaps/snapshots.md +++ b/tests/testthat/_snaps/snapshots.md @@ -1094,6 +1094,7 @@ Training data was an with: * Geography: state, + * Other keys: , * Time type: day, * Using data up-to-date as of: 2022-05-31. * With the last data available on 2021-12-31 @@ -1117,6 +1118,7 @@ Training data was an with: * Geography: state, + * Other keys: , * Time type: day, * Using data up-to-date as of: 2022-05-31. * With the last data available on 2021-12-31 @@ -1141,6 +1143,7 @@ Training data was an with: * Geography: state, + * Other keys: , * Time type: day, * Using data up-to-date as of: 2022-05-31. * With the last data available on 2021-12-31 diff --git a/tests/testthat/_snaps/step_epi_naomit.md b/tests/testthat/_snaps/step_epi_naomit.md new file mode 100644 index 00000000..653e84d0 --- /dev/null +++ b/tests/testthat/_snaps/step_epi_naomit.md @@ -0,0 +1,8 @@ +# Argument must be a recipe + + Code + step_epi_naomit(x) + Condition + Error in `step_epi_naomit()`: + ! inherits(recipe, "recipe") is not TRUE + diff --git a/tests/testthat/_snaps/step_epi_slide.md b/tests/testthat/_snaps/step_epi_slide.md index 7493a7fe..a21fd3f1 100644 --- a/tests/testthat/_snaps/step_epi_slide.md +++ b/tests/testthat/_snaps/step_epi_slide.md @@ -107,7 +107,7 @@ Code r %>% step_epi_slide(value) Condition - Error in `step_epi_slide()`: + Error in `rlang::is_formula()`: ! argument ".f" is missing, with no default --- @@ -123,7 +123,7 @@ Code r %>% step_epi_slide(value) Condition - Error in `step_epi_slide()`: + Error in `rlang::is_formula()`: ! argument ".f" is missing, with no default --- diff --git a/tests/testthat/_snaps/step_lag_difference.md b/tests/testthat/_snaps/step_lag_difference.md new file mode 100644 index 00000000..4edc9c28 --- /dev/null +++ b/tests/testthat/_snaps/step_lag_difference.md @@ -0,0 +1,72 @@ +# step_lag_difference validates arguments + + Code + step_lag_difference(r) + Condition + Error in `step_lag_difference()`: + ! This recipe step can only operate on an . + +--- + + Code + step_lag_difference(r, value, role = 1) + Condition + Error in `step_lag_difference()`: + ! `role` must be of type . + +--- + + Code + step_lag_difference(r, value, horizon = 0) + Condition + Error in `step_lag_difference()`: + ! `horizon` must be a positive integer. + +--- + + Code + step_lag_difference(r, value, prefix = letters[1:2]) + Condition + Error in `step_lag_difference()`: + ! `prefix` must be a scalar of type . + +--- + + Code + step_lag_difference(r, value, id = letters[1:2]) + Condition + Error in `step_lag_difference()`: + ! `id` must be a scalar of type . + +--- + + Code + step_lag_difference(r, value, prefix = letters[1:2]) + Condition + Error in `step_lag_difference()`: + ! `prefix` must be a scalar of type . + +--- + + Code + step_lag_difference(r, value, prefix = 1) + Condition + Error in `step_lag_difference()`: + ! `prefix` must be a scalar of type . + +--- + + Code + step_lag_difference(r, value, id = 1) + Condition + Error in `step_lag_difference()`: + ! `id` must be a scalar of type . + +--- + + Code + step_lag_difference(r, value, skip = 1) + Condition + Error in `step_lag_difference()`: + ! `skip` must be a scalar of type . +