Skip to content

Commit

Permalink
Merge pull request #404 from spsanderson/development
Browse files Browse the repository at this point in the history
Fixes #401
  • Loading branch information
spsanderson authored Feb 13, 2024
2 parents 337e0b0 + db6b5ff commit 7e9456d
Show file tree
Hide file tree
Showing 33 changed files with 85 additions and 68 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Description:
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
URL: https://www.spsanderson.com/TidyDensity/, https://github.com/spsanderson/TidyDensity
RoxygenNote: 7.3.1
URL: https://github.com/spsanderson/TidyDensity
BugReports: https://github.com/spsanderson/TidyDensity/issues
Depends:
R (>= 4.1.0)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ None
None

## Minor Fixes and Improvements
None
1. Fix #401 - Update `tidy_multi_single_dist()` to respect the `.return_tibble` parameter

# TidyDensity 1.3.0

Expand Down
27 changes: 16 additions & 11 deletions R/combine-multi-single-dist-tbl.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#' want to pass through to the TidyDensity `tidy_` distribution function.
#'
#' @examples
#'
#' tidy_multi_single_dist(
#' .tidy_dist = "tidy_normal",
#' .param_list = list(
Expand All @@ -29,6 +30,17 @@
#' )
#' )
#'
#' tidy_multi_single_dist(
#' .tidy_dist = "tidy_normal",
#' .param_list = list(
#' .n = 50,
#' .mean = c(-1, 0, 1),
#' .sd = 1,
#' .num_sims = 3,
#' .return_tibble = FALSE
#' )
#' )
#'
#' @return
#' A tibble
#'
Expand Down Expand Up @@ -70,16 +82,11 @@ tidy_multi_single_dist <- function(.tidy_dist = NULL,
# Run call on the grouped df ----
dff <- param_grid |>
dplyr::mutate(results = purrr::pmap(dplyr::pick(dplyr::everything()), match.fun(td)))
#dplyr::mutate(results = purrr::pmap(dplyr::cur_data(), match.fun(td)))

# Get the attributes to be used later on ----
atb <- dff$results[[1]] |> attributes()

# Make Dist Type for column ----
# dist_type <- stringr::str_remove(atb$tibble_type, "tidy_") |>
# stringr::str_replace_all(pattern = "_", " ") |>
# stringr::str_to_title()

dist_type <- dist_type_extractor(atb$tibble_type)

# Get column names from the param_grid in order to make teh dist_type column ----
Expand All @@ -95,19 +102,17 @@ tidy_multi_single_dist <- function(.tidy_dist = NULL,
)
}

# dff$dist_name <- paste0(
# paste0(dist_type, " c("),
# apply(dff[, cols], 1, paste0, collapse = ", "),
# ")"
# )

df_unnested_tbl <- dff |>
tidyr::unnest(results) |>
dplyr::ungroup() |>
dplyr::select(sim_number, dist_name, x:q) |>
dplyr::mutate(dist_name = as.factor(dist_name)) |>
dplyr::arrange(sim_number, dist_name)

if (params$.return_tibble == FALSE) {
df_unnested_tbl <- data.table::as.data.table(df_unnested_tbl)
}

# Attach attributes ----
attr(df_unnested_tbl, "all") <- atb
attr(df_unnested_tbl, "tibble_type") <- atb$tibble_type
Expand Down
4 changes: 2 additions & 2 deletions man/tidy_beta.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_burr.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_cauchy.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_chisquare.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_exponential.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_f.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_gamma.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_generalized_beta.Rd

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

6 changes: 3 additions & 3 deletions man/tidy_generalized_pareto.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_geometric.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_inverse_burr.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_inverse_exponential.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_inverse_gamma.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_inverse_normal.Rd

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

6 changes: 3 additions & 3 deletions man/tidy_inverse_pareto.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_inverse_weibull.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_logistic.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_lognormal.Rd

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

12 changes: 12 additions & 0 deletions man/tidy_multi_single_dist.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_normal.Rd

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

4 changes: 2 additions & 2 deletions man/tidy_paralogistic.Rd

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

Loading

0 comments on commit 7e9456d

Please sign in to comment.