151
151
# ' attr(ex3, "metadata")
152
152
NULL
153
153
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.
162
165
# ' @param as_of Time value representing the time at which the given data were
163
166
# ' available. For example, if `as_of` is January 31, 2022, then the `epi_df`
164
167
# ' object that is created would represent the most up-to-date version of the
165
168
# ' data available as of January 31, 2022. If the `as_of` argument is missing,
166
169
# ' 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).
169
172
# ' @param ... Additional arguments passed to methods.
170
173
# ' @return An `epi_df` object.
171
174
# '
172
175
# ' @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 ,
174
178
other_keys = character (), ... ) {
175
179
# Define metadata fields
176
180
metadata <- list ()
@@ -195,7 +199,8 @@ new_epi_df <- function(x = tibble::tibble(), geo_type, time_type, as_of,
195
199
return (x )
196
200
}
197
201
198
- # ' @rdname epi_df
202
+ # ' @describeIn epi_df The preferred way of constructing `epi_df`s
203
+ # ' @order 1
199
204
# ' @param x An `epi_df`, `data.frame`, [tibble::tibble], or [tsibble::tsibble]
200
205
# ' to be converted
201
206
# ' @param ... used for specifying column names, as in [`dplyr::rename`]. For
@@ -206,17 +211,19 @@ as_epi_df <- function(x, ...) {
206
211
}
207
212
208
213
# ' @rdname epi_df
214
+ # ' @order 1
209
215
# ' @method as_epi_df epi_df
210
216
# ' @export
211
217
as_epi_df.epi_df <- function (x , ... ) {
212
218
return (x )
213
219
}
214
220
215
221
# ' @rdname epi_df
216
- # ' @method as_epi_df tbl_df
222
+ # ' @order 1
217
223
# ' @importFrom rlang .data
218
224
# ' @importFrom tidyselect any_of
219
225
# ' @importFrom cli cli_inform
226
+ # ' @method as_epi_df tbl_df
220
227
# ' @export
221
228
as_epi_df.tbl_df <- function (
222
229
x ,
@@ -273,15 +280,17 @@ as_epi_df.tbl_df <- function(
273
280
new_epi_df(x , geo_type , time_type , as_of , other_keys )
274
281
}
275
282
276
- # ' @method as_epi_df data.frame
277
283
# ' @rdname epi_df
284
+ # ' @order 1
285
+ # ' @method as_epi_df data.frame
278
286
# ' @export
279
287
as_epi_df.data.frame <- function (x , as_of , other_keys = character (), ... ) {
280
288
as_epi_df.tbl_df(x = tibble :: as_tibble(x ), as_of = as_of , other_keys = other_keys , ... )
281
289
}
282
290
283
- # ' @method as_epi_df tbl_ts
284
291
# ' @rdname epi_df
292
+ # ' @order 1
293
+ # ' @method as_epi_df tbl_ts
285
294
# ' @export
286
295
as_epi_df.tbl_ts <- function (x , as_of , other_keys = character (), ... ) {
287
296
tsibble_other_keys <- setdiff(tsibble :: key_vars(x ), " geo_value" )
0 commit comments