Skip to content

Commit

Permalink
updated extract function #120
Browse files Browse the repository at this point in the history
  • Loading branch information
abhsarma committed Aug 3, 2024
1 parent c02d072 commit 3d5ea7c
Show file tree
Hide file tree
Showing 51 changed files with 710 additions and 30 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ importFrom(styler,style_text)
importFrom(tibble,as_tibble)
importFrom(tibble,tibble)
importFrom(tidyr,nest)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,unnest_longer)
importFrom(tidyr,unnest_wider)
importFrom(tidyselect,everything)
importFrom(tidyselect,starts_with)
Expand Down
14 changes: 11 additions & 3 deletions R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,23 @@
#' "trim_5pc" ~ 0.025,
#' "trim_10pc" ~ 0.05
#' ))
#'
#' y <- sd(data)
#' })
#'
#' # Extracts the relevant variable from the multiverse
#' M %>%
#' extract_variables(x.mean)
#'
#' # if you want to filter the multiverse before extracting variables from it
#' # you ca first create the table and manipulate it before extracting variables
#' # you can first create the table and manipulate it before extracting variables
#' expand(M) %>%
#' extract_variables(x.mean)
#'
#' # you can extract more than one variable from the multiverse simultaneously
#' # these variables will be new columns in the dataset
#' expand(M) %>%
#' extract_variables(x.mean, y)
#' }
#'
#' @importFrom tidyr unnest_wider
Expand All @@ -71,8 +78,9 @@ extract_variables.data.frame <- function(x, ..., .results = .results) {

mutate(
x, extracted = lapply(!!.results, extract_from_env, ...)
) %>%
unnest_wider("extracted")
) |>
unnest_longer(extracted) |>
pivot_wider(names_from = extracted_id, values_from = extracted)
}

extract_from_env <- function(.env, ...) {
Expand Down
1 change: 1 addition & 0 deletions docs/404.html

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

1 change: 1 addition & 0 deletions docs/LICENSE-text.html

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

3 changes: 2 additions & 1 deletion docs/articles/branch.html

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

3 changes: 2 additions & 1 deletion docs/articles/conditions.html

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

3 changes: 2 additions & 1 deletion docs/articles/example-dance.html

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

3 changes: 2 additions & 1 deletion docs/articles/example-durante.html

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

3 changes: 2 additions & 1 deletion docs/articles/example-frequentist.html

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

3 changes: 2 additions & 1 deletion docs/articles/example-hurricane.html

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

3 changes: 2 additions & 1 deletion docs/articles/execution-multiverse.html

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

Loading

0 comments on commit 3d5ea7c

Please sign in to comment.