Skip to content

Commit

Permalink
Fix #70
Browse files Browse the repository at this point in the history
  • Loading branch information
spsanderson committed Feb 28, 2022
1 parent 44958b6 commit bee76f1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ the legend argument would fail.
8. Fix #61 - Update `_pkgdown.yml` file to update site.
9. Fix #67 - Add `param_grid`, `param_grid_txt`, and `dist_with_params` to the
attributes of all `tidy_` distribution functions.
10. Fix #70 - Add `...` as a grouping parameter to `tidy_distribution_summary_tbl()`

# TidyDensity 0.0.1

Expand Down
19 changes: 16 additions & 3 deletions R/tidy_distribution_summary_tbl.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,30 @@
#'
#' @param .data The data that is going to be passed from a a `tidy_` distribution
#' function.
#' @param ... This is the grouping variable that gets passed to [dplyr::group_by()]
#' and [dplyr::select()].
#'
#' @examples
#' library(dplyr)
#'
#' tn <- tidy_normal(.num_sims = 5)
#' tb <- tidy_beta(.num_sims = 5)
#'
#' tidy_distribution_summary_tbl(tn)
#' tidy_distribution_summary_tbl(tn, sim_number)
#'
#' data_tbl <- tidy_combine_distributions(tn, tb)
#'
#' tidy_distribution_summary_tbl(data_tbl)
#' tidy_distribution_summary_tbl(data_tbl, dist_type)
#'
#' @return
#' A summary stats tibble
#'
#' @export
#'

tidy_distribution_summary_tbl <- function(.data) {
tidy_distribution_summary_tbl <- function(.data, ...) {

# Get the data attributes
atb <- attributes(.data)
Expand All @@ -48,8 +61,8 @@ tidy_distribution_summary_tbl <- function(.data) {
data_tbl <- dplyr::as_tibble(.data)

summary_tbl <- data_tbl %>%
dplyr::group_by(sim_number) %>%
dplyr::select(sim_number, y) %>%
dplyr::group_by(...) %>%
dplyr::select(..., y) %>%
dplyr::summarise(
mean_val = mean(y, na.rm = TRUE),
median_val = stats::median(y, na.rm = TRUE),
Expand Down
16 changes: 15 additions & 1 deletion man/tidy_distribution_summary_tbl.Rd

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

0 comments on commit bee76f1

Please sign in to comment.