Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
qddyy committed Oct 26, 2024
1 parent 48375c2 commit ee1c9ae
Show file tree
Hide file tree
Showing 20 changed files with 45 additions and 46 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Title: 'R6'-Based Flexible Framework for Permutation Tests
Version: 1.2.3
Authors@R:
person(given = "Yan", family = "Du", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0009-0009-1169-921X"))
Description: Implements non-parametric tests from Higgins (2004, ISBN:0534387756), including one-sample, two-sample, k-sample, paired comparison, randomized complete block design, correlation and contingency table tests. Built with 'Rcpp' for efficiency and 'R6' for flexible, object-oriented design, the package provides a unified framework for performing or creating custom permutation tests.
Description: Implements non-parametric tests from Higgins (2004, ISBN:0534387756), including tests for one sample, two samples, k samples, paired comparisons, blocked designs, trends and association. Built with 'Rcpp' for efficiency and 'R6' for flexible, object-oriented design, the package provides a unified framework for performing or creating custom permutation tests.
BugReports: https://github.com/qddyy/LearnNonparam/issues
URL: https://github.com/qddyy/LearnNonparam, https://qddyy.github.io/LearnNonparam/
License: GPL (>= 2)
Expand All @@ -22,4 +22,4 @@ Suggests:
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
21 changes: 11 additions & 10 deletions R/pmt.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ pmts <- function(
#' @param alternative a character string specifying the alternative of the test.
#' @param depends,plugins,includes passed to [Rcpp::cppFunction()].
#'
#' @return a test object based on the specified statistic.
#'
#' @details The test statistic in `define_pmt` can be defined using either `R` or `Rcpp`, with the `statistic` parameter specified as:
#'
#' - `R`: a function returning a closure that returns a double.
#' - `Rcpp`: a character string defining a captureless lambda (introduced in C++11) returning another lambda that may capture by value, accepts const arguments of the same type, and returns a double.
#' - `Rcpp`: a character string defining a captureless lambda (since C++11) returning another lambda that captures by value, accepts parameters of the same type as const references, and returns a double.
#'
#' When using `Rcpp`, the parameters for different `inherit` are listed as follows. Note that the parameter names are illustrative and may be modified.
#'
Expand All @@ -133,10 +135,10 @@ pmts <- function(
#' rcpp <- define_pmt(
#' inherit = "twosample", rejection = "lr", n_permu = 1e5,
#' statistic = "[](NumericVector x, NumericVector y) {
#' R_len_t n_x = x.size();
#' R_len_t n_y = y.size();
#' return [n_x, n_y](const NumericVector x, const NumericVector y) -> double {
#' return sum(x) / n_x - sum(y) / n_y;
#' R_len_t m = x.size();
#' R_len_t n = y.size();
#' return [=](const NumericVector& x, const NumericVector& y) -> double {
#' return sum(x) / m - sum(y) / n;
#' };
#' }"
#' )
Expand Down Expand Up @@ -201,7 +203,7 @@ define_pmt <- function(
plugins = unique(c(plugins, "cpp14")),
includes = {
hpps <- c("progress", "reorder", impl)
c(includes, paste0("#include <pmt/", hpps, ".hpp>"))
c(includes, paste0("#include<pmt/", hpps, ".hpp>"))
},
code = {
n <- if (inherit == "rcbd") 2 else 3
Expand All @@ -212,11 +214,10 @@ define_pmt <- function(
", double n_permu, bool progress){",
"auto statistic = ", statistic, ";",
"return progress ?", paste0(
impl, "<PermuBar",
c("Show", "Hide"), ">(",
impl, "<PermuBar", c("Show", "Hide"), ">(",
paste0(
"clone(", args[-n], ")", collapse = ", "
), ", statistic, n_permu)", collapse = " : "
"clone(", args[-n], ")", collapse = ","
), ", statistic, n_permu )", collapse = ":"
), ";}"
)
}
Expand Down
3 changes: 2 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ do_call <- function(func, default = NULL, fixed = NULL, ...) {
env_args <- list2env(list(...), envir = env_args)
env_args <- list2env(as.list(fixed), envir = env_args)

args <- names(env_args)
eval(
as.call(c(func, sapply(names(env_args), as.name, simplify = FALSE))),
as.call(c(func, lapply(`names<-`(args, args), as.name))),
envir = env_args, enclos = parent.frame()
)
}
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ options(

## Overview

This R package implements several non-parametric tests in chapters 1-5 of [@higgins2004](#references), including one-sample, two-sample, k-sample, paired comparison, randomized complete block design, correlation and contingency table tests. Built with [Rcpp](https://CRAN.R-project.org/package=Rcpp) for efficiency and [R6](https://CRAN.R-project.org/package=R6) for flexible, object-oriented design, the package provides a unified framework for performing or creating custom permutation tests.
This R package implements several non-parametric tests in chapters 1-5 of [@higgins2004](#references), including tests for one sample, two samples, k samples, paired comparisons, blocked designs, trends and association. Built with [Rcpp](https://CRAN.R-project.org/package=Rcpp) for efficiency and [R6](https://CRAN.R-project.org/package=R6) for flexible, object-oriented design, it provides a unified framework for performing or creating custom permutation tests.

## Installation

Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ downloads](https://cranlogs.r-pkg.org/badges/grand-total/LearnNonparam)](https:/
## Overview

This R package implements several non-parametric tests in chapters 1-5
of [Higgins (2004)](#references), including one-sample, two-sample,
k-sample, paired comparison, randomized complete block design,
correlation and contingency table tests. Built with
[Rcpp](https://CRAN.R-project.org/package=Rcpp) for efficiency and
[R6](https://CRAN.R-project.org/package=R6) for flexible,
object-oriented design, the package provides a unified framework for
of [Higgins (2004)](#references), including tests for one sample, two
samples, k samples, paired comparisons, blocked designs, trends and
association. Built with [Rcpp](https://CRAN.R-project.org/package=Rcpp)
for efficiency and [R6](https://CRAN.R-project.org/package=R6) for
flexible, object-oriented design, it provides a unified framework for
performing or creating custom permutation tests.

## Installation
Expand Down
2 changes: 1 addition & 1 deletion man/figures/README/define-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/figures/README/define.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/figures/README/modify-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/figures/README/modify.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/figures/README/p_value-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ee1c9ae

Please sign in to comment.