From 9c5ff0715329a28ad92c125f0e9856f82ff131a3 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Mon, 5 Aug 2024 14:40:47 -0700 Subject: [PATCH] fix+doc: ?epi_df works again --- R/epi_df.R | 35 +++++++++++++++++++++++++++++------ man-roxygen/epi_df-params.R | 18 ------------------ man/epi_df.Rd | 6 ++++-- 3 files changed, 33 insertions(+), 26 deletions(-) delete mode 100644 man-roxygen/epi_df-params.R diff --git a/R/epi_df.R b/R/epi_df.R index b3958f065..96af0f6bc 100644 --- a/R/epi_df.R +++ b/R/epi_df.R @@ -81,10 +81,7 @@ #' #' An unrecognizable time type is labeled "custom". #' -#' @template epi_df-params -#' @rdname epi_df -#' -#' @export +#' @name epi_df #' @examples #' # Convert a `tsibble` that has county code as an extra key #' # Notice that county code should be a character string to preserve any leading zeroes @@ -154,6 +151,30 @@ #' as_epi_df(additional_metadata = list(other_keys = c("state", "pol"))) #' #' attr(ex3, "metadata") +NULL + +#' Create an `epi_df` object +#' +#' @rdname epi_df +#' @param geo_type DEPRECATED Has no effect. Geo value type is inferred from the +#' location column and set to "custom" if not recognized. +#' @param time_type DEPRECATED Has no effect. Time value type inferred from the time +#' column and set to "custom" if not recognized. Unpredictable behavior may result +#' if the time type is not recognized. +#' @param as_of Time value representing the time at which the given data were +#' available. For example, if `as_of` is January 31, 2022, then the `epi_df` +#' object that is created would represent the most up-to-date version of the +#' data available as of January 31, 2022. If the `as_of` argument is missing, +#' then the current day-time will be used. +#' @param additional_metadata List of additional metadata to attach to the +#' `epi_df` object. The metadata will have `geo_type`, `time_type`, and +#' `as_of` fields; named entries from the passed list will be included as +#' well. If your tibble has additional keys, be sure to specify them as a +#' character vector in the `other_keys` component of `additional_metadata`. +#' @param ... Additional arguments passed to methods. +#' @return An `epi_df` object. +#' +#' @export new_epi_df <- function(x = tibble::tibble(), geo_type, time_type, as_of, additional_metadata = list()) { # Define metadata fields @@ -180,6 +201,8 @@ new_epi_df <- function(x = tibble::tibble(), geo_type, time_type, as_of, } #' @rdname epi_df +#' @param x An `epi_df`, `data.frame`, [tibble::tibble], or [tsibble::tsibble] +#' to be converted #' @param ... used for specifying column names, as in [`dplyr::rename`]. For #' example, `geo_value = STATEFP, time_value = end_date`. #' @export @@ -187,15 +210,15 @@ as_epi_df <- function(x, ...) { UseMethod("as_epi_df") } -#' @method as_epi_df epi_df #' @rdname epi_df +#' @method as_epi_df epi_df #' @export as_epi_df.epi_df <- function(x, ...) { return(x) } -#' @method as_epi_df tbl_df #' @rdname epi_df +#' @method as_epi_df tbl_df #' @importFrom rlang .data #' @importFrom tidyselect any_of #' @importFrom cli cli_inform diff --git a/man-roxygen/epi_df-params.R b/man-roxygen/epi_df-params.R deleted file mode 100644 index bedcb7d48..000000000 --- a/man-roxygen/epi_df-params.R +++ /dev/null @@ -1,18 +0,0 @@ -#' @param x A data.frame, [tibble::tibble], or [tsibble::tsibble] to be converted -#' @param geo_type DEPRECATED Has no effect. Geo value type is inferred from the -#' location column and set to "custom" if not recognized. -#' @param time_type DEPRECATED Has no effect. Time value type inferred from the time -#' column and set to "custom" if not recognized. Unpredictable behavior may result -#' if the time type is not recognized. -#' @param as_of Time value representing the time at which the given data were -#' available. For example, if `as_of` is January 31, 2022, then the `epi_df` -#' object that is created would represent the most up-to-date version of the -#' data available as of January 31, 2022. If the `as_of` argument is missing, -#' then the current day-time will be used. -#' @param additional_metadata List of additional metadata to attach to the -#' `epi_df` object. The metadata will have `geo_type`, `time_type`, and -#' `as_of` fields; named entries from the passed list will be included as -#' well. If your tibble has additional keys, be sure to specify them as a -#' character vector in the `other_keys` component of `additional_metadata`. -#' @param ... Additional arguments passed to methods. -#' @return An `epi_df` object. diff --git a/man/epi_df.Rd b/man/epi_df.Rd index 84e943b47..dcda08722 100644 --- a/man/epi_df.Rd +++ b/man/epi_df.Rd @@ -1,6 +1,7 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/epi_df.R -\name{new_epi_df} +\name{epi_df} +\alias{epi_df} \alias{new_epi_df} \alias{as_epi_df} \alias{as_epi_df.epi_df} @@ -35,7 +36,8 @@ as_epi_df(x, ...) \method{as_epi_df}{tbl_ts}(x, as_of, additional_metadata = list(), ...) } \arguments{ -\item{x}{A data.frame, \link[tibble:tibble]{tibble::tibble}, or \link[tsibble:tsibble]{tsibble::tsibble} to be converted} +\item{x}{An \code{epi_df}, \code{data.frame}, \link[tibble:tibble]{tibble::tibble}, or \link[tsibble:tsibble]{tsibble::tsibble} +to be converted} \item{geo_type}{DEPRECATED Has no effect. Geo value type is inferred from the location column and set to "custom" if not recognized.}