Skip to content
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

Speedups for epix_slide #386

Merged
merged 19 commits into from
Dec 14, 2023
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
11 changes: 7 additions & 4 deletions R/grouped_epi_archive.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ grouped_epi_archive =
#' object. See the documentation for the wrapper function [`epix_slide()`] for
#' details.
#' @importFrom data.table key address rbindlist
#' @importFrom tibble as_tibble
#' @importFrom rlang !! !!! enquo quo_is_missing enquos is_quosure sym syms
#' env missing_arg
slide = function(f, ..., before, ref_time_values,
Expand Down Expand Up @@ -280,16 +281,18 @@ grouped_epi_archive =
if (! (is.atomic(comp_value) || is.data.frame(comp_value))) {
Abort("The slide computation must return an atomic vector or a data frame.")
}
# Convert from data.frame to tibble for speed.
# Label every result row with the `ref_time_value`
res <- as_tibble(data.frame(time_value = ref_time_value))
nmdefries marked this conversation as resolved.
Show resolved Hide resolved

# Wrap the computation output in a list and unchop/unnest later if
# `as_list_col = FALSE`. This approach means that we will get a
# list-class col rather than a data.frame-class col when
# `as_list_col = TRUE` and the computations outputs are data
# frames.
comp_value <- list(comp_value)
res[[new_col]] <- list(comp_value)

# Label every result row with the `ref_time_value`:
return(tibble::tibble(time_value = .env$ref_time_value,
!!new_col := .env$comp_value))
return(res)
}

# If `f` is missing, interpret ... as an expression for tidy evaluation
Expand Down
Loading