Skip to content

Addressed the sources of the conflicts between epipredict and epiprocess (see Issue 104 in epipredict) #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 5 additions & 32 deletions R/methods-epi_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,51 +69,24 @@ summary.epi_df = function(object, ...) {

if (!is.data.frame(res)) return(res)

i_arg <- substitute(i)
j_arg <- substitute(j)

if (missing(i)) {
i <- NULL
i_arg <- NULL
} else if (is.null(i)) {
i <- integer()
}
}

if (missing(j)) {
j <- NULL
j_arg <- NULL
} else if (is.null(j)) {
j <- integer()
}

# Ignore drop as an argument for counting
n_real_args <- nargs() - !missing(drop)

# Case when the number of args (excluding drop) is not 3 or more
if (n_real_args <= 2L) {
j <- i
i <- NULL
j_arg <- i_arg
i_arg <- NULL
}
}

cn <- names(res)
nr <- vctrs::vec_size(x)
not_epi_df <- (!("time_value" %in% cn) || !("geo_value" %in% cn) || vctrs::vec_size(res) > nr || any(i > nr))

if (not_epi_df) return(tibble::as_tibble(res))

# Case when i is numeric and there are duplicate values in it
if (is.numeric(i) && vctrs::vec_duplicate_any(i) > 0)
return(tibble::as_tibble(res))
if (not_epi_df) return(tibble::as_tibble(res))

att_x = attr(x, "metadata")
new_epi_df(tibble::as_tibble(res),
geo_type = att_x$geo_type,
time_type = att_x$time_type,
as_of = att_x$as_of,
additional_metadata =
att_x[!(names(att_x) %in% c("geo_type", "time_type", "as_of"))])
# Use reclass as safeguard (in case class & metadata are dropped)
reclass(res, attr(x, "metadata"))
}

#' `dplyr` verbs
Expand Down
12 changes: 4 additions & 8 deletions man/as_epi_archive.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/as_epi_df.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions man/epi_archive.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions man/epi_slide.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions man/epix_as_of.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions man/epix_slide.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.