From 4a49f4b2fea96ad89c39a0db59d3ce006a267c04 Mon Sep 17 00:00:00 2001 From: egouldo Date: Sun, 11 Aug 2024 12:44:08 +1000 Subject: [PATCH] #102 update roxygen examples and doc /document --- R/utils.R | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/R/utils.R b/R/utils.R index a1611c2..6cbdf22 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,8 +1,9 @@ #' 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 @@ -10,13 +11,14 @@ #' @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 @@ -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 @@ -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( @@ -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 }}) %>%