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

118 log transform yi #121

Merged
merged 104 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 93 commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
d2ab529
#118 add option to `log_transform()` in `prepare_response_variables()`
egouldo Aug 15, 2024
44c2e76
#118 create `log_transform_yi()`
egouldo Aug 15, 2024
671fa50
Fix #118 apply log-transformation in `prepare_response_variables()`
egouldo Aug 15, 2024
89947c1
#116 #97 update argument checks
egouldo Aug 15, 2024
a9a3f61
Update `pred_toZ()`
egouldo Aug 15, 2024
d45f471
Update `standardise_response()`
egouldo Aug 15, 2024
332d251
#118 update `process_response()` to match log-transformation and stan…
egouldo Aug 15, 2024
e199dfb
#118 add function `log_transform_response()`
egouldo Aug 15, 2024
5af7899
#118 update application of `prepare_response_variables()` in targets …
egouldo Aug 15, 2024
000eb65
#118 #97 #102 devtools::document()
egouldo Aug 15, 2024
eedf931
Increment version number to 2.5.0
egouldo Aug 15, 2024
8e5a7cf
#118 rm call to redundant arg in pred_to_Z()
egouldo Aug 15, 2024
a61ada1
upgrade '2.5.1' to Version
egouldo Aug 15, 2024
babbf8a
#118 delete prev. data assignment occurring in middle of unfinished a…
egouldo Aug 15, 2024
d8ceeb6
#118 Increment version and update description
egouldo Aug 15, 2024
a8f5456
#118 rm redundant code erroneously left-behind
egouldo Aug 15, 2024
00d32d0
#97 increment patch version
egouldo Aug 15, 2024
b22133a
#118 replace second `.x` arg with `.y` arg in `map2()` call
egouldo Aug 15, 2024
4461d69
#118 fix omission of case when estimate_type is Zr and NULL args supp…
egouldo Aug 15, 2024
52ad119
increment patch version #97
egouldo Aug 15, 2024
d258f69
#118 assign names to fns stored in tibbles
egouldo Aug 22, 2024
ad957f2
#118 update arguments in *_response() fns
egouldo Aug 23, 2024
5ddb518
#118 mv fn-specific arguments out of topic roxygen block
egouldo Aug 23, 2024
8c015a4
#91 remove arg matching for ManyAnalysts specific datasets
egouldo Aug 23, 2024
a25b7ed
#118 #102 add example code for `standardise_response()` and update ex…
egouldo Aug 23, 2024
84176be
#118 add ... arg for using in pmap
egouldo Aug 23, 2024
75a0631
#118 #102 update seealso doc
egouldo Aug 23, 2024
e7da50b
#97 update cli formatting
egouldo Aug 23, 2024
ba6cf17
- #118 add pmap internal helper function for differential application…
egouldo Aug 23, 2024
effb92b
#118 add ... arg to prepare_response_variables()
egouldo Aug 23, 2024
032244f
#118 #102 add example code
egouldo Aug 23, 2024
3d45d72
- Update arg supply to targets call on prepare_response_variables() a…
egouldo Aug 23, 2024
ee5b6fa
#102 #118 devtools::document()
egouldo Aug 23, 2024
bae1420
#97 update version description
egouldo Aug 23, 2024
f2a4ff9
#97 fledge::update_news()
egouldo Aug 23, 2024
d409381
#118 #102 export log_transform_response()
egouldo Aug 23, 2024
4a5a5fa
#118 add check for col estimate_type existing, create it when FALSE
egouldo Aug 23, 2024
62bee48
- #118 docs: Add explanation about updated behaviour when `estimate_t…
egouldo Aug 23, 2024
e34aec1
Increment version number to 2.6.0.9000
egouldo Aug 23, 2024
f834047
#97 docs: update news
egouldo Aug 23, 2024
4ceec4d
#118 #97 make new name for processed output and return object using n…
egouldo Aug 23, 2024
fe6ee93
#118 fix: conditional application of log_transform_yi
egouldo Aug 23, 2024
ea032bc
#88 fix: ensure log_transform also calculates SE and not SD
egouldo Aug 23, 2024
d367f3f
Increment version number to 2.6.0.9001
egouldo Aug 23, 2024
f1ea09b
#118 update generate_yi_subsets() to deal with changes in prepare_res…
egouldo Aug 23, 2024
bad02b3
#97 rm todos
egouldo Aug 23, 2024
f568822
Increment version number to 2.6.0.9002
egouldo Aug 23, 2024
02d058e
- refactor!: exposed argument in `exclude_extreme_VZ()` to allow diff…
egouldo Aug 24, 2024
7dabe6d
docs: Update documentation for most functions
egouldo Aug 24, 2024
b53d3e4
update comments and lint spacing #97
egouldo Aug 24, 2024
98ed2e2
build!: update call to `apply_VZ_exclusions()` after 02d058e0a2918543…
egouldo Aug 24, 2024
9ef1127
build!: increment version and `devtools::document()` #118 #97
egouldo Aug 24, 2024
5a6126c
fix: Fix roxygen entries with missing `@family` tag #118 and `devtool…
egouldo Aug 24, 2024
a40db1d
docs: update roxygen documentation
egouldo Aug 26, 2024
41767fe
style: save intermediate output to object `out` and return
egouldo Aug 26, 2024
4b6631d
style: namespace function call
egouldo Aug 26, 2024
6841a89
feat: Add `pointblank::` column checks and user warnings #116
egouldo Aug 26, 2024
7515021
fix: wrap column names in c() when checking if exist #116
egouldo Aug 26, 2024
8869ca2
style!: replace call to `pointblank::cars()` with `c()` since is supe…
egouldo Aug 26, 2024
bd04529
bug: don't use reserved data pronoun as argument `.data`
egouldo Aug 26, 2024
29cfbdf
docs!: switch to import from importFrom #102
egouldo Aug 26, 2024
e8f354b
fix!: breaking changes to `generate_outlier_subsets()`
egouldo Aug 26, 2024
b3e80f2
feat!: update downstream fns #118
egouldo Aug 27, 2024
c913fd8
style: linespace / indentation linting
egouldo Aug 27, 2024
4645c74
bug: fix improper mixing of `cli` braces in calls to `glue::glue`, sw…
egouldo Aug 27, 2024
84b73b6
style: indentation / linespacing
egouldo Aug 27, 2024
421e02f
feat: add argument checks #116 #97
egouldo Aug 27, 2024
d47c02b
bug!: replace transmute with mutate in addition to .keep = unused arg…
egouldo Aug 27, 2024
7a9e9ba
style!: explicitly call `by =` arg on joins
egouldo Aug 27, 2024
c603106
style: indentation #97
egouldo Aug 27, 2024
684a880
bug!: fix `cli` expressions, rm improper use of `glue::glue()` #97
egouldo Aug 27, 2024
fa4386d
bug!: fix `@imports` #97 #102
egouldo Aug 27, 2024
2503588
feat: expose `poss_fit_sorensen_glm()`
egouldo Aug 27, 2024
1f3d13a
docs!: fix broekn links to topics in roxygen2 markdown
egouldo Aug 27, 2024
ec19f1f
docs!: `devtools::document()`
egouldo Aug 27, 2024
a679cbb
build!: update targets pipeline to reflect all #118 changes
egouldo Aug 27, 2024
d494c3f
Increment version number to 2.6.0.9004
egouldo Aug 27, 2024
bdf5375
feat!: update downstream fn `meta_analyse_datasets()` post-#118 updates
egouldo Aug 28, 2024
4b228cb
feat!: update meta-analysis function arguments cf. changes in bdf5375…
egouldo Aug 28, 2024
25418a1
bug!: bug-fixes after testing #118 on yi pipeline
egouldo Aug 28, 2024
c8cb70a
style: indentation
egouldo Aug 28, 2024
3027ede
Increment version number to 2.6.0.9005
egouldo Aug 28, 2024
196d66a
build!: fix missing comma between target arguments
egouldo Aug 28, 2024
330bd6c
docs!: `devtools::document()`
egouldo Aug 28, 2024
a0d5b14
- docs!: update `@imports` #102
egouldo Aug 28, 2024
045ec1a
docs!: #102 add `@import*` calls
egouldo Aug 28, 2024
4a1ebb1
docs!: update `@import` tags
egouldo Aug 28, 2024
b0083fe
add TODO comment
egouldo Aug 28, 2024
61903dd
docs!: `devtools::document()` #102
egouldo Aug 28, 2024
1bada9b
build!: `renv::snapshot()`
egouldo Aug 28, 2024
b4ddecc
build!: set pipeline targets seed
egouldo Aug 28, 2024
4fb2dc4
build!: BREAKING CHANGES `targets::tar_make()`
egouldo Aug 28, 2024
79be4c8
Increment version
egouldo Aug 28, 2024
a2a9868
Update R/generate_exclusion_subsets.R
egouldo Aug 28, 2024
5697f35
Update R/generate_exclusion_subsets.R
egouldo Aug 28, 2024
85ce711
Update R/generate_exclusion_subsets.R
egouldo Aug 28, 2024
1d2f197
Update R/generate_exclusion_subsets.R
egouldo Aug 28, 2024
7b71fda
Update R/generate_exclusion_subsets.R
egouldo Aug 28, 2024
8424016
Update R/box_cox_transform.R
egouldo Aug 28, 2024
9e4cebb
Update R/box_cox_transform.R
egouldo Aug 28, 2024
5e78393
Update R/box_cox_transform.R
egouldo Aug 28, 2024
d43a5e1
Update R/box_cox_transform.R
egouldo Aug 28, 2024
2a4b01d
Update R/box_cox_transform.R
egouldo Aug 28, 2024
807c548
Merge branch 'main' into 118-log-transform-yi
egouldo Aug 28, 2024
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ManyEcoEvo
Title: Meta-analyse data from 'Many-Analysts' style studies
Version: 2.4.2
Version: 2.7.0
Authors@R: c(
person("Elliot", "Gould", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "https://orcid.org/0000-0002-6585-538X")),
Expand Down
2 changes: 1 addition & 1 deletion ManyEcoEvo.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ LaTeX: pdfLaTeX
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace,vignette
PackageRoxygenize: rd,collate,namespace
114 changes: 99 additions & 15 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export(fit_metafor_uni)
export(fit_multivar_MA)
export(fit_sorensen_glm)
export(fit_uni_mixed_effects)
export(folded_params)
export(generate_collinearity_subset)
export(generate_exclusion_subsets)
export(generate_expertise_subsets)
Expand All @@ -59,6 +60,8 @@ export(identity_back)
export(inverse_back)
export(log_back)
export(log_transform)
export(log_transform_response)
export(log_transform_yi)
export(logit_back)
export(make_param_table)
export(make_viz)
Expand All @@ -85,8 +88,10 @@ export(preprocess_prediction_files)
export(preprocess_updated_prediction_files)
export(probit_back)
export(read_submission_data)
export(rename_prediction_cols)
export(rm_inf_na)
export(run_model_checks)
export(split_yi_subsets)
export(square_back)
export(square_root_back)
export(standardise_response)
Expand All @@ -106,72 +111,151 @@ export(summarise_study)
export(summarise_variable_counts)
export(validate_predictions)
export(validate_predictions_df_blue_tit)
export(validate_predictions_df_euc)
import(NatParksPalettes)
import(broom)
import(broom.mixed)
import(cli)
export(variance_box_cox)
import(dplyr)
import(forcats)
import(ggbeeswarm)
import(ggforestplot)
import(ggplot2)
import(lme4)
import(metafor)
import(purrr)
import(recipes)
import(rlang)
import(see)
import(stringr)
import(tidyr)
importFrom(EnvStats,stat_n_text)
importFrom(broom.mixed,tidy)
importFrom(NatParksPalettes,scale_color_natparks_d)
importFrom(betapart,beta.pair)
importFrom(broom,tidy)
importFrom(cli,cli_abort)
importFrom(cli,cli_alert)
importFrom(cli,cli_alert_danger)
importFrom(cli,cli_alert_info)
importFrom(cli,cli_alert_success)
importFrom(cli,cli_alert_warning)
importFrom(cli,cli_bullets)
importFrom(cli,cli_h1)
importFrom(cli,cli_h2)
importFrom(cli,cli_ol)
importFrom(cli,cli_warn)
importFrom(cli,style_italic)
importFrom(data.table,setnames)
importFrom(forcats,as_factor)
importFrom(forcats,fct_relevel)
importFrom(forcats,fct_reorder)
importFrom(fs,file_exists)
importFrom(ggbeeswarm,geom_quasirandom)
importFrom(ggforestplot,theme_forest)
importFrom(ggplot2,aes)
importFrom(ggplot2,coord_flip)
importFrom(ggplot2,element_line)
importFrom(ggplot2,element_text)
importFrom(ggplot2,geom_pointrange)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,guides)
importFrom(ggplot2,labs)
importFrom(ggplot2,theme)
importFrom(glue,glue)
importFrom(lifecycle,deprecated)
importFrom(lme4,lmer)
importFrom(magrittr,"%>%")
importFrom(metafor,rma.mv)
importFrom(metaviz,viz_funnel)
importFrom(orchaRd,i2_ml)
importFrom(parameters,parameters)
importFrom(parsnip,fit)
importFrom(parsnip,linear_reg)
importFrom(performance,performance)
importFrom(pointblank,action_levels)
importFrom(pointblank,col_exists)
importFrom(pointblank,col_is_character)
importFrom(pointblank,col_is_integer)
importFrom(pointblank,col_is_numeric)
importFrom(pointblank,col_vals_in_set)
importFrom(pointblank,col_vals_not_null)
importFrom(pointblank,create_agent)
importFrom(pointblank,expect_col_exists)
importFrom(pointblank,expect_col_is_character)
importFrom(pointblank,expect_col_is_numeric)
importFrom(pointblank,expect_col_vals_in_set)
importFrom(pointblank,has_columns)
importFrom(pointblank,stop_if_not)
importFrom(pointblank,test_col_exists)
importFrom(pointblank,test_col_vals_gte)
importFrom(pointblank,vars)
importFrom(pointblank,warn_on_fail)
importFrom(purrr,discard)
importFrom(purrr,exec)
importFrom(purrr,flatten_dbl)
importFrom(purrr,is_scalar_vector)
importFrom(purrr,keep)
importFrom(purrr,keep_at)
importFrom(purrr,list_c)
importFrom(purrr,list_flatten)
importFrom(purrr,list_rbind)
importFrom(purrr,map)
importFrom(purrr,map2)
importFrom(purrr,map_chr)
importFrom(purrr,map_dfr)
importFrom(purrr,map_if)
importFrom(purrr,map_int)
importFrom(purrr,map_lgl)
importFrom(purrr,pluck)
importFrom(purrr,pmap)
importFrom(purrr,possibly)
importFrom(purrr,reduce)
importFrom(purrr,reduce2)
importFrom(purrr,set_names)
importFrom(purrr,simplify)
importFrom(purrr,transpose)
importFrom(readr,read_csv)
importFrom(recipes,juice)
importFrom(recipes,prep)
importFrom(recipes,recipe)
importFrom(recipes,step_mutate)
importFrom(recipes,step_naomit)
importFrom(recipes,tidy)
importFrom(recipes,update_role)
importFrom(rlang,"!!")
importFrom(rlang,":=")
importFrom(rlang,as_function)
importFrom(rlang,as_string)
importFrom(rlang,caller_env)
importFrom(rlang,enquo)
importFrom(rlang,ensym)
importFrom(rlang,exec)
importFrom(rlang,expr)
importFrom(rlang,exprs)
importFrom(rlang,f_lhs)
importFrom(rlang,inject)
importFrom(rlang,is_call)
importFrom(rlang,is_list)
importFrom(rlang,is_na)
importFrom(rlang,is_null)
importFrom(rlang,na_chr)
importFrom(rlang,new_formula)
importFrom(sae,bxcx)
importFrom(see,geom_jitter2)
importFrom(see,scale_fill_material_d)
importFrom(see,theme_modern)
importFrom(stringr,str_detect)
importFrom(stringr,str_remove)
importFrom(stringr,str_split)
importFrom(stringr,str_starts)
importFrom(tibble,as_tibble)
importFrom(tibble,as_tibble_row)
importFrom(tibble,column_to_rownames)
importFrom(tibble,enframe)
importFrom(tibble,rownames_to_column)
importFrom(tibble,tibble)
importFrom(tidyr,any_of)
importFrom(tidyr,drop_na)
importFrom(tidyr,hoist)
importFrom(tidyr,nest)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,separate)
importFrom(tidyr,tibble)
importFrom(tidyr,unite)
importFrom(tidyr,unnest)
importFrom(tidyr,unnest_longer)
importFrom(tidyselect,all_of)
importFrom(tidyselect,where)
importFrom(timetk,step_box_cox)
importFrom(workflows,add_model)
importFrom(workflows,add_recipe)
importFrom(workflows,extract_fit_parsnip)
importFrom(workflows,workflow)
32 changes: 29 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# ManyEcoEvo 2.4.2
# ManyEcoEvo (development version)

# ManyEcoEvo 2.4.1
<!-- NEWS.md is maintained by https://cynkra.github.io/fledge, do not edit -->

* Initial CRAN submission.
- #118 docs: Add explanation about updated behaviour when `estimate_type` is missing in `ManyEcoEvo` dataframe
- #118 build: devtools::document()

# ManyEcoEvo 2.6.0

- Update arg supply to targets call on prepare_response_variables() after #118 updates
- #118 add pmap internal helper function for differential application of transformation / standardisation in `standardise_response()`
- #118 delete old pmap helper function
- `dat` to `data` to help with auto-matching in pmap within prepare_response_variables() wrapper #118
- ensure all family fns have ... arg for pmap application in prepare_response_variables() since all fns have different argument lengths and names
- accidentally deleted when upgrading for #118, have added creation of transform_datasets tibbles for all cases now, and then these will apply the appropriate functions in final code chunk at end
- #118 ensure application of Z_VZ_preds takes the generalised colnames yi, yi_se instead of using hard-coded dataset application #97
- #118 call new arg `dataset_log_transform` in fn to log-transform outcomes for euc yi analysis
- #118 add log-transformation equivalent to `standardise_response()` and `process_resonse()`
- #102 add function documentation, including examples
- #118 extract `lower` and `upper` transformed vals in line with addition of `log_transform_response()` / changes to `standardise_response()`
- #116 check appropriate required variable (i.e. function needs `back_transformed_data`, but checked for `augmented_data` in `dat` arg, wouldn't throw required error because `augmented_data` was present in `dat`
- #102 add import, return, and see also roxygen doc tags, replace note with details tag, rename fn doc title
- #116 update argument checks conditional expression
- #118 match output to `log_transform_yi()` (now returns additional cols `lower` and `upper`, not only `c("Z","VZ")`)
- #118 match process to `log_transform_yi()` and #97 generalise processing to both euc/bt datasets without hard-coding dataset names in fns, and remove associated dataset-specific argument checking #116
- #118 adapt response variable preparation to accept additional argument `dataset_log_transform` apply argument checks #116, add roxygen param #102
- #118 adapt response variable processing to accept either/or/none for dataset standardisation/log-transformation.
- equivalent to `pred_to_z()`
- #102 write documentation
- #102 add import tags for `log_transform()` and link to equivalent functions, apply default argument values / checks
- #97 rename out argument
1 change: 0 additions & 1 deletion R/ManyEcoEvo-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"_PACKAGE"

## usethis namespace: start
#' @import rlang
#' @importFrom glue glue
#' @importFrom lifecycle deprecated
## usethis namespace: end
Expand Down
2 changes: 1 addition & 1 deletion R/anonymise_teams.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @return A `df` with anonymised values of `id_col` based on the `New_Identifier` colum of `lookup`
#' @export
#' @importFrom pointblank col_vals_not_null
#' @import tidyr
#' @importFrom tidyr separate unite
#' @import dplyr
anonymise_teams <- function(df, lookup) { # TODO actually... this is anonymise_id_col()
df %>%
Expand Down
124 changes: 116 additions & 8 deletions R/apply_VZ_exclusions.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,130 @@
#' Apply VZ exclusion to a data-frame containing list-columns of yi subsets
#'
#' @param df A dataframe of yi data subsets generated from `generate_yi_subsets\(\)`.
#' @param VZ_cutoff A numeric vector of length 1, values equal to or greater than this value of VZ will be filtered out of the dataframes stored in `df`'s list-column `data`.
#'
#' @param df A dataframe of yi data subsets generated by [generate_yi_subsets()] or [split_yi_subsets()].
#' @param VZ_cutoff A numeric vector of length 1, values equal to or greater than this value of VZ will be filtered out of the dataframes stored in `df`'s list-column `data`, else a named list of numeric values, where the names are the dataset names and the values are the `VZ_cutoff`s for each `dataset` in `df`.

Check notice on line 4 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L4

Lines should not be more than 120 characters. This line is 313 characters. (line_length_linter)
#' @param VZ_colname Either A character vector of length 1, the name of the column in the dataframes stored in `df`'s list-column `data` that contains the VZ values. Or else a named list of character values, where the names are the dataset names and the values are the `VZ_colname`s for each `dataset` in `df`.

Check notice on line 5 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L5

Lines should not be more than 120 characters. This line is 311 characters. (line_length_linter)
#' @return A dataframe of yi subsets, whose extreme values of VZ have been removed.
#' @export
#' @import dplyr
#' @importFrom purrr map map2
#' @importFrom pointblank col_exists
#' @importFrom cli cli_alert_warning
#' @seealso Applies [exclude_extreme_VZ()] to each dataframe in the list-column `data` of `df`.
#' @family Multi-dataset Wrapper Functions
apply_VZ_exclusions <- function(df = data.frame(), VZ_cutoff = numeric(1L)) {
pointblank::col_exists(df, columns = c("data", "diversity_data"))

#' @details
#' `df` must contain the columns `"data"`, `"diversity_data"` and `"dataset"`.
#' If only one value of `VZ_colname` and `VZ_cutoff` is supplied, it will be recycled to match the number of datasets in `df`.

Check notice on line 16 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L16

Lines should not be more than 120 characters. This line is 126 characters. (line_length_linter)
#'

Check notice on line 17 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L17

Remove trailing whitespace. (trailing_whitespace_linter)
#' If a named list is supplied for `VZ_colname` and `VZ_cutoff`, the names must match the dataset names in `df`.
#' @examples
#' data(ManyEcoEvo_yi)
#' ManyEcoEvo_yi %>%
#' prepare_response_variables(
#' estimate_type = "yi",
#' param_table =
#' ManyEcoEvo:::analysis_data_param_tables,
#' dataset_standardise = "blue tit",
#' dataset_log_transform = "eucalyptus") %>%
#' generate_yi_subsets() %>%

Check notice on line 28 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L28

Remove trailing whitespace. (trailing_whitespace_linter)
#' apply_VZ_exclusions(VZ_colname =

Check notice on line 29 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L29

Remove trailing whitespace. (trailing_whitespace_linter)
#' list("eucalyptus" = "se_log",

Check notice on line 30 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L30

Remove trailing whitespace. (trailing_whitespace_linter)
#' "blue tit" = "VZ"),

Check notice on line 31 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L31

Remove trailing whitespace. (trailing_whitespace_linter)
#' VZ_cutoff = 3)
apply_VZ_exclusions <- function(df = data.frame(), VZ_colname, VZ_cutoff) {

Check notice on line 33 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L33

Variable and function name style should match snake_case or symbols. (object_name_linter)

Check notice on line 33 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L33

Variable and function name style should match snake_case or symbols. (object_name_linter)

Check notice on line 33 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L33

Variable and function name style should match snake_case or symbols. (object_name_linter)
# ---- Argument Checking -----
pointblank::col_exists(df, columns = c("data", "diversity_data", "dataset"))

Check notice on line 36 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L36

Remove trailing whitespace. (trailing_whitespace_linter)
if (!is.null(names(VZ_colname))) {
pointblank::expect_col_vals_make_set(object = df,

Check notice on line 38 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L38

Remove trailing whitespace. (trailing_whitespace_linter)
columns = dataset,

Check notice on line 39 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L39

Remove trailing whitespace. (trailing_whitespace_linter)
set = names(VZ_colname))
}

Check notice on line 42 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L42

Remove trailing whitespace. (trailing_whitespace_linter)
if (!is.null(names(VZ_cutoff))) {
pointblank::expect_col_vals_make_set(object = df,

Check notice on line 44 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L44

Remove trailing whitespace. (trailing_whitespace_linter)
columns = dataset,

Check notice on line 45 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L45

Remove trailing whitespace. (trailing_whitespace_linter)
set = names(VZ_cutoff))
}

Check notice on line 48 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L48

Remove trailing whitespace. (trailing_whitespace_linter)
cli::cli_h1("Applying VZ exclusions")

Check notice on line 50 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L50

Remove trailing whitespace. (trailing_whitespace_linter)
if (is.list(VZ_colname)) {
map(VZ_colname, ~ {
stopifnot(
is.character(.x)
)
})
} else {
stopifnot(
is.character(VZ_colname)
)
# ----- Format VZ exclusions when VZ_colname is not list -----
if (length(VZ_colname) < length(unique(df$dataset))) {
cli::cli_alert_warning("{.arg VZ_colname} = {.val {VZ_cutoff}} was recycled to match the number of unique datasets in {.arg df}.")

Check notice on line 63 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L63

Lines should not be more than 120 characters. This line is 136 characters. (line_length_linter)
VZ_colname <- rep(VZ_colname, length(unique(df$dataset)))

Check notice on line 64 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L64

Variable and function name style should match snake_case or symbols. (object_name_linter)
}
}

Check notice on line 67 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L67

Remove trailing whitespace. (trailing_whitespace_linter)
if (is.list(VZ_cutoff)) {
map(VZ_cutoff, ~ {
stopifnot(
is.numeric(.x)
)
})
} else {
stopifnot(
is.numeric(VZ_cutoff)
)
# ----- Format VZ exclusions when VZ_cutoff is not list -----
if (length(VZ_cutoff) < length(unique(df$dataset))) {
cli::cli_alert_warning("{.arg VZ_cutoff} = {.val {VZ_cutoff}} was recycled to match the number of unique datasets in {.arg df}.")

Check notice on line 80 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L80

Lines should not be more than 120 characters. This line is 135 characters. (line_length_linter)
VZ_cutoff <- rep(VZ_cutoff, length(unique(df$dataset)))

Check notice on line 81 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L81

Variable and function name style should match snake_case or symbols. (object_name_linter)
}
}

Check notice on line 84 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L84

Remove trailing whitespace. (trailing_whitespace_linter)
# ----- Create formulas for matching VZ_cutoff and VZ_colname to df$dataset -----

Check notice on line 86 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L86

Remove trailing whitespace. (trailing_whitespace_linter)
if (is.list(VZ_colname)) {
formulae_match_VZ_colname <- map2(names(VZ_colname),

Check notice on line 88 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L88

Variable and function name style should match snake_case or symbols. (object_name_linter)

Check notice on line 88 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L88

Remove trailing whitespace. (trailing_whitespace_linter)
VZ_colname,

Check notice on line 89 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L89

Remove trailing whitespace. (trailing_whitespace_linter)
rlang::new_formula)
} else {
formulae_match_VZ_colname <- map2(unique(df$dataset),

Check notice on line 92 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L92

Remove trailing whitespace. (trailing_whitespace_linter)

Check notice on line 92 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L92

Variable and function name style should match snake_case or symbols. (object_name_linter)
VZ_colname,

Check notice on line 93 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L93

Remove trailing whitespace. (trailing_whitespace_linter)
rlang::new_formula)
}

Check notice on line 96 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L96

Remove trailing whitespace. (trailing_whitespace_linter)
if (is.list(VZ_cutoff)) {
formulae_match_VZ_cutoff <- map2(names(VZ_cutoff),

Check notice on line 98 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L98

Remove trailing whitespace. (trailing_whitespace_linter)

Check notice on line 98 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L98

Variable and function name style should match snake_case or symbols. (object_name_linter)
VZ_cutoff,

Check notice on line 99 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L99

Remove trailing whitespace. (trailing_whitespace_linter)
rlang::new_formula)
} else {
formulae_match_VZ_cutoff <- map2(unique(df$dataset),

Check notice on line 102 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L102

Remove trailing whitespace. (trailing_whitespace_linter)

Check notice on line 102 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L102

Variable and function name style should match snake_case or symbols. (object_name_linter)
VZ_cutoff,

Check notice on line 103 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L103

Remove trailing whitespace. (trailing_whitespace_linter)
rlang::new_formula)
}

Check notice on line 106 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L106

Remove trailing whitespace. (trailing_whitespace_linter)
# ----- Apply VZ exclusions -----
df_out <- df %>%
ungroup() %>%

Check notice on line 109 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L109

Remove trailing whitespace. (trailing_whitespace_linter)
mutate(
data = map(data, exclude_extreme_VZ, !!{{ VZ_cutoff }}), # TODO check whether we should run on effects_analysis instead of data
VZ_colname_val = case_match(dataset,
!!!formulae_match_VZ_colname,
.default = NA),

Check notice on line 113 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L113

Remove trailing whitespace. (trailing_whitespace_linter)
VZ_cutoff_val = case_match(dataset,
!!!formulae_match_VZ_cutoff,
.default = NA),
data = pmap( # TODO check whether we should run on effects_analysis instead of data
list(data, VZ_colname_val, VZ_cutoff_val),
~ exclude_extreme_VZ(df = ..1, VZ_colname = ..2, VZ_cutoff = ..3)
),
diversity_data = map2(
.x = diversity_data,
.y = data,
.f = ~ semi_join(.x, .y, by = "id_col")
)
)
) %>%

Check notice on line 126 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L126

Remove trailing whitespace. (trailing_whitespace_linter)
select(-VZ_colname_val, -VZ_cutoff_val)

Check notice on line 128 in R/apply_VZ_exclusions.R

View check run for this annotation

codefactor.io / CodeFactor

R/apply_VZ_exclusions.R#L128

Remove trailing whitespace. (trailing_whitespace_linter)
return(df_out)
}
Loading