Skip to content

Commit

Permalink
#102 update roxygen examples and doc /document
Browse files Browse the repository at this point in the history
  • Loading branch information
egouldo committed Aug 11, 2024
1 parent ecc85c7 commit 4a49f4b
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#' Negative Value Matching
#'
#' See \code{base::[](`%in%`)} for details. %nin% is a binary operator, returning a logical vector indicating if there is a negative match or not.
#' See \code{base::[](`%in%`)} for details. `%nin%` is a binary operator,
#' returning a logical vector indicating if there is a negative match or not.
#'
#' @name %in%
#' @name %nin%
#' @rdname NotIn
#' @keywords internal
#' @export
#' @usage lhs \%in\% rhs
#' @param lhs vector or NULL: the values to be matched. [Long vectors](http://127.0.0.1:59782/help/library/base/help/Long%20vectors) are supported.
#' @param rhs vector or NULL: the values to be matched. [Long vectors](http://127.0.0.1:59782/help/library/base/help/Long%20vectors) are supported.
#' @return A logical vector indicating which value of `lhs` are *not* matched in `rhs`
#' @examples
#' "A" %nin% LETTERS[1:10]
#' "A" %in% LETTERS[1:10]
`%nin%` <- Negate(`%in%`)



#' Subsetting Functions for Zr analysis
#' Subsetting Functions for effect-size meta-analysis
#'
#' @description Generates a list of functions that are used to subset the processed ManyEcoEvo dataset
#' @description Generates a list of functions that are used to subset the processed [ManyEcoEvo::] dataset
#'
#' @return A named list of `lambda` functions
#' @export
Expand All @@ -38,9 +40,15 @@ subset_fns_Zr <- function() { # TODO update calling of this fn (switch to fn rat
return(out)
}

#' Subsetting Functions for yi analysis
#' Subsetting Functions for out-of-sample predictions meta-analysis
#'
#' @description Generates a list of functions that are used to subset the processed ManyEcoEvo dataset containing out-of-sample predictions \(\code{y\_i}\)
#' @description Generates a list of functions that are used to subset the
#' processed ManyEcoEvo dataset (e.g.`data(ManyEcoEvo_results`) containing
#' out-of-sample predictions $y_i$.
#'
#' @details
#' The subset functions are used to filter out predictions that are not
#' to be included in the meta-analysis.
#'
#' @return A named list of `lambda` functions
#' @export
Expand Down Expand Up @@ -77,16 +85,19 @@ capwords <- function(s, strict = FALSE) {
sapply(strsplit(s, split = " "), cap, USE.NAMES = !is.null(names(s)))
}



#' Removes infinite and NA values from a dataframe of standardised effects
#'
#' @param Z_colname unquoted or bare column name with the Z or Zr estimates
#' @param VZ_colname unquoted or bare column name containing the VZ or VZr estimates
#' @param effects_analysis A dataframe containing the standardised effects
#' @param Z_colname unquoted or bare column name with the $Z$ or $Z_r$ estimates
#' @param VZ_colname unquoted or bare column name containing the $VZ$ or $\text{VZ}_r$ estimates
#'
#' @return a dataframe without
#' @export
#' @examples
#' data(ManyEcoEvo_results)
#' ManyEcoEvo_results %>%
#' pluck("effects_analysis", 1) %>%
#' rm_inf_na(beta_estimate, beta_SE)
rm_inf_na <- function(effects_analysis, Z_colname, VZ_colname) {
effects_analysis %>%
filter(
Expand All @@ -108,8 +119,10 @@ rm_inf_na <- function(effects_analysis, Z_colname, VZ_colname) {
#' @export
#' @importFrom dplyr group_split
#' @examples
#' named_group_split(ManyEcoEvo::euc_data, Property)
#' named_group_split(ManyEcoEvo::blue_tit_data, hatch_Area)
#' data(euc_data)
#' data(blue_tit_data)
#' named_group_split(euc_data, Property)
#' named_group_split(blue_tit_data, hatch_Area)
named_group_split <- function(.data, grouping_variable) {
.data %>%
group_by({{ grouping_variable }}) %>%
Expand Down

0 comments on commit 4a49f4b

Please sign in to comment.