From 581a9ab2ff45f7aaf55a4f7d11617a484c597b51 Mon Sep 17 00:00:00 2001 From: Brandon LeBeau Date: Fri, 15 Mar 2024 10:35:24 -0500 Subject: [PATCH] attempt to revert back --- NAMESPACE | 1 - R/parse_formula.r | 36 ----------------------------------- R/pow_sim.r | 17 ++++++----------- man/parse_varyarguments_mf.Rd | 23 ---------------------- 4 files changed, 6 insertions(+), 71 deletions(-) delete mode 100644 man/parse_varyarguments_mf.Rd diff --git a/NAMESPACE b/NAMESPACE index 99fd4a5..7304c41 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -17,7 +17,6 @@ export(parse_multiplemember) export(parse_power) export(parse_randomeffect) export(parse_varyarguments) -export(parse_varyarguments_mf) export(parse_varyarguments_w) export(random_missing) export(rbimod) diff --git a/R/parse_formula.r b/R/parse_formula.r index 6028fb9..b6eb240 100644 --- a/R/parse_formula.r +++ b/R/parse_formula.r @@ -245,9 +245,6 @@ parse_varyarguments_w <- function(sim_args, name) { names = name, exclude = FALSE), KEEP.OUT.ATTRS = FALSE) - # conditions <- list_select(sim_args[['vary_arguments']], - # names = name, - # exclude = FALSE) if(any(sapply(conditions, is.list))) { loc <- sapply(conditions, is.list) simp_conditions <- conditions[loc != TRUE] @@ -268,39 +265,6 @@ parse_varyarguments_w <- function(sim_args, name) { } } -#' Parse within varying arguments -#' -#' @param sim_args A named list with special model formula syntax. See details and examples -#' for more information. The named list may contain the following: -#' \itemize{ -#' \item fixed: This is the fixed portion of the model (i.e. covariates) -#' \item random: This is the random portion of the model (i.e. random effects) -#' \item error: This is the error (i.e. residual term). -#' } -#' @param name The name of the within simulation condition. This is primarily -#' an internal function. -#' -#' @export -parse_varyarguments_mf <- function(sim_args, name) { - - conditions <- list_select(sim_args[['vary_arguments']], - names = name, - exclude = FALSE) - if(any(sapply(conditions, is.list))) { - loc <- sapply(conditions, is.list) - list_conditions <- conditions[loc == TRUE] - update_conditions <- lapply(seq_along(conditions), function(xx) c(sim_args, - model_fit = list_conditions[xx])) - for(xx in seq_along(update_conditions)) { - names(update_conditions[[xx]]) <- gsub("\\..*", "", names(update_conditions[[xx]])) - } - } else { - lapply(1:nrow(conditions), function(xx) c(sim_args, - conditions[xx, , drop = FALSE])) - } - -} - #' Parse correlation arguments #' diff --git a/R/pow_sim.r b/R/pow_sim.r index fbf3889..3a0c831 100644 --- a/R/pow_sim.r +++ b/R/pow_sim.r @@ -145,25 +145,20 @@ replicate_simulation_vary <- function(sim_args, return_list = FALSE, within_conditions <- list_select(sim_args[['vary_arguments']], names = c('model_fit'), exclude = FALSE, simplify = FALSE) - if(length(within_conditions) > 0 ) { - within_conditions_name <- names( - list_select(sim_args[['vary_arguments']], - names = c('model_fit'), - exclude = FALSE, simplify = TRUE) - ) - } between_conditions <- list_select(sim_args[['vary_arguments']], names = c('model_fit', 'power'), exclude = TRUE, simplify = FALSE) between_conditions_name <- data.frame(sapply(expand.grid(between_conditions, KEEP.OUT.ATTRS = FALSE), as.character)) + within_conditions_name <- data.frame(sapply(expand.grid(within_conditions, KEEP.OUT.ATTRS = FALSE), + as.character)) sim_arguments <- parse_varyarguments(sim_args) - if(length(within_conditions) > 0) { - sim_arguments_w <- parse_varyarguments_mf(sim_args, name = c('model_fit')) + if(length(within_conditions_name) > 0) { + sim_arguments_w <- parse_varyarguments_w(sim_args, name = c('model_fit')) if(any(unlist(lapply(seq_along(sim_arguments_w), function(xx) sim_arguments_w[[xx]][['model_fit']] |> names())) == 'name')) { @@ -190,7 +185,7 @@ replicate_simulation_vary <- function(sim_args, return_list = FALSE, }, future.seed = future.seed) }, future.seed = future.seed) } - if(length(within_conditions) == 0) { + if(length(within_conditions_name) == 0) { power_out <- future.apply::future_lapply(seq_along(sim_arguments), function(xx) { future.apply::future_replicate(sim_arguments[[xx]][['replications']], @@ -215,7 +210,7 @@ replicate_simulation_vary <- function(sim_args, return_list = FALSE, rep(1:sim_args[['replications']], each = num_rows[xx]/sim_args[['replications']])) - if(length(within_conditions) > 0) { + if(length(within_conditions_name) > 0) { num_terms <- lapply(seq_along(power_out), function(xx) lapply(seq_along(power_out[[xx]]), function(yy) lapply(power_out[[xx]][[yy]], nrow)) diff --git a/man/parse_varyarguments_mf.Rd b/man/parse_varyarguments_mf.Rd deleted file mode 100644 index 9ddcbcb..0000000 --- a/man/parse_varyarguments_mf.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/parse_formula.r -\name{parse_varyarguments_mf} -\alias{parse_varyarguments_mf} -\title{Parse within varying arguments} -\usage{ -parse_varyarguments_mf(sim_args, name) -} -\arguments{ -\item{sim_args}{A named list with special model formula syntax. See details and examples -for more information. The named list may contain the following: -\itemize{ - \item fixed: This is the fixed portion of the model (i.e. covariates) - \item random: This is the random portion of the model (i.e. random effects) - \item error: This is the error (i.e. residual term). -}} - -\item{name}{The name of the within simulation condition. This is primarily -an internal function.} -} -\description{ -Parse within varying arguments -}