151151# ' attr(ex3, "metadata")
152152NULL
153153
154- # ' Create an `epi_df` object
155- # '
156- # ' @rdname epi_df
157- # ' @param geo_type DEPRECATED Has no effect. Geo value type is inferred from the
158- # ' location column and set to "custom" if not recognized.
159- # ' @param time_type DEPRECATED Has no effect. Time value type inferred from the time
160- # ' column and set to "custom" if not recognized. Unpredictable behavior may result
161- # ' if the time type is not recognized.
154+ # ' @describeIn epi_df Lower-level constructor for `epi_df` object
155+ # ' @order 2
156+ # ' @param geo_type `r lifecycle::badge("deprecated")` in `as_epi_df()`, has no
157+ # ' effect; the geo value type is inferred from the location column and set to
158+ # ' "custom" if not recognized. In `new_epi_df()`, should be set to the same
159+ # ' value that would be inferred.
160+ # ' @param time_type `r lifecycle::badge("deprecated")` in `as_epi_df()`, has no
161+ # ' effect: the time value type inferred from the time column and set to
162+ # ' "custom" if not recognized. Unpredictable behavior may result if the time
163+ # ' type is not recognized. In `new_epi_df()`, should be set to the same value
164+ # ' that would be inferred.
162165# ' @param as_of Time value representing the time at which the given data were
163166# ' available. For example, if `as_of` is January 31, 2022, then the `epi_df`
164167# ' object that is created would represent the most up-to-date version of the
165168# ' data available as of January 31, 2022. If the `as_of` argument is missing,
166169# ' then the current day-time will be used.
167- # ' @param other_keys If your tibble has additional keys, be sure to specify them as a
168- # ' character vector here (typical examples are "age" or sub-geographies).
170+ # ' @param other_keys If your tibble has additional keys, be sure to specify them
171+ # ' as a character vector here (typical examples are "age" or sub-geographies).
169172# ' @param ... Additional arguments passed to methods.
170173# ' @return An `epi_df` object.
171174# '
172175# ' @export
173- new_epi_df <- function (x = tibble :: tibble(), geo_type , time_type , as_of ,
176+ new_epi_df <- function (x = tibble :: tibble(geo_value = character (), time_value = as.Date(integer())),
177+ geo_type , time_type , as_of ,
174178 other_keys = character (), ... ) {
175179 # Define metadata fields
176180 metadata <- list ()
@@ -195,7 +199,8 @@ new_epi_df <- function(x = tibble::tibble(), geo_type, time_type, as_of,
195199 return (x )
196200}
197201
198- # ' @rdname epi_df
202+ # ' @describeIn epi_df The preferred way of constructing `epi_df`s
203+ # ' @order 1
199204# ' @param x An `epi_df`, `data.frame`, [tibble::tibble], or [tsibble::tsibble]
200205# ' to be converted
201206# ' @param ... used for specifying column names, as in [`dplyr::rename`]. For
@@ -206,17 +211,19 @@ as_epi_df <- function(x, ...) {
206211}
207212
208213# ' @rdname epi_df
214+ # ' @order 1
209215# ' @method as_epi_df epi_df
210216# ' @export
211217as_epi_df.epi_df <- function (x , ... ) {
212218 return (x )
213219}
214220
215221# ' @rdname epi_df
216- # ' @method as_epi_df tbl_df
222+ # ' @order 1
217223# ' @importFrom rlang .data
218224# ' @importFrom tidyselect any_of
219225# ' @importFrom cli cli_inform
226+ # ' @method as_epi_df tbl_df
220227# ' @export
221228as_epi_df.tbl_df <- function (
222229 x ,
@@ -273,15 +280,17 @@ as_epi_df.tbl_df <- function(
273280 new_epi_df(x , geo_type , time_type , as_of , other_keys )
274281}
275282
276- # ' @method as_epi_df data.frame
277283# ' @rdname epi_df
284+ # ' @order 1
285+ # ' @method as_epi_df data.frame
278286# ' @export
279287as_epi_df.data.frame <- function (x , as_of , other_keys = character (), ... ) {
280288 as_epi_df.tbl_df(x = tibble :: as_tibble(x ), as_of = as_of , other_keys = other_keys , ... )
281289}
282290
283- # ' @method as_epi_df tbl_ts
284291# ' @rdname epi_df
292+ # ' @order 1
293+ # ' @method as_epi_df tbl_ts
285294# ' @export
286295as_epi_df.tbl_ts <- function (x , as_of , other_keys = character (), ... ) {
287296 tsibble_other_keys <- setdiff(tsibble :: key_vars(x ), " geo_value" )
0 commit comments