diff --git a/R/ContingencyTableTest.R b/R/ContingencyTableTest.R index 884526ed..42b9846c 100644 --- a/R/ContingencyTableTest.R +++ b/R/ContingencyTableTest.R @@ -19,7 +19,7 @@ ContingencyTableTest <- R6Class( } private$.data <- unname( - do_call(cbind, lapply(private$.raw_data, as.integer)) + do.call(cbind, lapply(private$.raw_data, as.integer)) ) if (any(private$.data < 0)) { diff --git a/R/RCBDTest.R b/R/RCBDTest.R index 9ac0b78b..65179ea3 100644 --- a/R/RCBDTest.R +++ b/R/RCBDTest.R @@ -18,7 +18,7 @@ RCBDTest <- R6Class( stop("All samples must be of equal length") } - private$.data <- unname(do_call(cbind, private$.raw_data)) + private$.data <- unname(do.call(cbind, private$.raw_data)) }, .calculate_score = function() { diff --git a/R/TwoSampleAssociationTest.R b/R/TwoSampleAssociationTest.R index a196ad5e..c18e80cd 100644 --- a/R/TwoSampleAssociationTest.R +++ b/R/TwoSampleAssociationTest.R @@ -20,7 +20,7 @@ TwoSampleAssociationTest <- R6Class( stop("Both samples must be of equal length") } - private$.data <- do_call(data.frame, private$.data) + private$.data <- do.call(data.frame, private$.data) }, .calculate_score = function() {}, diff --git a/R/TwoSamplePairedTest.R b/R/TwoSamplePairedTest.R index fffe20b6..1a98f97c 100644 --- a/R/TwoSamplePairedTest.R +++ b/R/TwoSamplePairedTest.R @@ -20,7 +20,7 @@ TwoSamplePairedTest <- R6Class( stop("Both samples must be of equal length") } - private$.data <- do_call(data.frame, private$.data) + private$.data <- do.call(data.frame, private$.data) }, .calculate_score = function() {}, diff --git a/R/utils.R b/R/utils.R index 3d0ec142..92f48666 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,14 +1,3 @@ -do_call <- function(func, default = NULL, fixed = NULL, ...) { - env_args <- list2env(as.list(default)) - env_args <- list2env(list(...), envir = env_args) - env_args <- list2env(as.list(fixed), envir = env_args) - - eval( - as.call(c(func, sapply(names(env_args), as.name, simplify = FALSE))), - envir = env_args, enclos = parent.frame() - ) -} - # for test() get_data <- function(call, env) { @@ -43,6 +32,19 @@ get_data <- function(call, env) { ), data_names) } +# for plot() + +do_call <- function(func, default = NULL, fixed = NULL, ...) { + env_args <- list2env(as.list(default)) + env_args <- list2env(list(...), envir = env_args) + env_args <- list2env(as.list(fixed), envir = env_args) + + eval( + as.call(c(func, sapply(names(env_args), as.name, simplify = FALSE))), + envir = env_args, enclos = parent.frame() + ) +} + # for .calculate_score() get_score <- function(x, method, n = length(x)) {