Skip to content

Commit 3ee11aa

Browse files
committed
docs(sum_groups_epi_df): tweak sum_cols roxygen, examples, code comments
1 parent b56d555 commit 3ee11aa

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Collate:
104104
'methods-epi_archive.R'
105105
'grouped_epi_archive.R'
106106
'growth_rate.R'
107+
'inline-roxygen.R'
107108
'key_colnames.R'
108109
'methods-epi_df.R'
109110
'outliers.R'

R/methods-epi_df.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -499,31 +499,31 @@ group_epi_df <- function(x, exclude = character()) {
499499
#' the resulting `epi_df` will have `geo_value` set to `"total"`.
500500
#'
501501
#' @param .x an `epi_df`
502-
#' @param sum_cols <[`tidy-select`][dplyr::dplyr_tidy_select]> One unquoted
503-
#' expression. Variable names can be used as if they like `c(x, y)`
504-
#' were positions in the data frame, and expressions like `x:y` can
505-
#' be used to select a range of variables.
502+
#' @param sum_cols `r tidyselect_arg_roxygen`
506503
#' @param group_cols character vector of column names to group by. "time_value" is
507504
#' included by default.
508505
#' @return an `epi_df` object
509506
#'
510-
#' @export
511507
#' @examples
512-
#' # This data has other_keys age_group and edu_qual.
513-
#' # We can aggregate num_graduates within geo_value
508+
#' # This data has other_keys age_group and edu_qual:
514509
#' grad_employ_subset
515-
#'
510+
#'
511+
#' # Aggregate num_graduates within each geo_value (and time_value):
516512
#' grad_employ_subset %>%
517513
#' sum_groups_epi_df(num_graduates, group_cols = "geo_value")
514+
#'
515+
#' @export
518516
sum_groups_epi_df <- function(.x, sum_cols, group_cols = "time_value") {
519517
assert_class(.x, "epi_df")
520518
assert_character(group_cols)
521519
checkmate::assert_subset(group_cols, key_colnames(.x))
522520
if (!"time_value" %in% group_cols) {
523521
group_cols <- c("time_value", group_cols)
524522
}
523+
# Attempt tidyselection ourselves to get "Error in `sum_groups_epi_df()`"
524+
# rather than "in `dplyr::summarize()`", before forwarding:
525525
sum_cols <- rlang::enquo(sum_cols)
526-
pos <- tidyselect::eval_select(sum_cols, .x) # trigger this to ensure cols exist
526+
pos <- tidyselect::eval_select(sum_cols, .x)
527527
out <- group_by(.x, across(all_of(group_cols))) %>%
528528
dplyr::summarize(across(!!sum_cols, sum), .groups = "drop")
529529

R/slide.R

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,7 @@ get_before_after_from_window <- function(window_size, align, time_type) {
557557
#' `vignette("epi_df")` for more examples.
558558
#'
559559
#' @template basic-slide-params
560-
#' @param .col_names <[`tidy-select`][dplyr_tidy_select]> An unquoted column
561-
#' name (e.g., `cases`), multiple column names (e.g., `c(cases, deaths)`),
562-
#' [other tidy-select expression][tidyselect::language], or a vector of
563-
#' characters (e.g. `c("cases", "deaths")`). Variable names can be used as if
564-
#' they were positions in the data frame, so expressions like `x:y` can be
565-
#' used to select a range of variables.
560+
#' @param .col_names `r tidyselect_arg_roxygen`
566561
#'
567562
#' The tidy-selection renaming interface is not supported, and cannot be used
568563
#' to provide output column names; if you want to customize the output column

man/sum_groups_epi_df.Rd

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)