Skip to content

Commit

Permalink
modified some text
Browse files Browse the repository at this point in the history
  • Loading branch information
qddyy committed Feb 7, 2024
1 parent 3d89d03 commit 8342ebd
Show file tree
Hide file tree
Showing 7 changed files with 397 additions and 390 deletions.
2 changes: 1 addition & 1 deletion R/PermuTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ PermuTest <- R6Class(
#' @description Plot histogram(s) of the permutation distribution. Note that it works only if the test's type is `"permu"`.
#'
#' @template plot_params
#' @param ... extra parameters passed to `graphics::hist` or `ggplot2::stat_bin`.
#' @param ... extra parameters passed to `graphics::hist()` or `ggplot2::stat_bin()`.
#'
#' @return The object itself (invisibly).
plot = function(style = c("graphics", "ggplot2"), ...) {
Expand Down
6 changes: 3 additions & 3 deletions R/pmt.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#' @title Syntactic Sugar for Object Construction
#'
#' @description construct a test object in a unified way.
#' @description construct test objects in a unified way.
#'
#' @name pmt


#' @rdname pmt
#'
#' @param key a character string corresponding to the desired test. Check `pmts` for valid keys.
#' @param key a character string corresponding to the desired test. Check `pmts()` for valid keys.
#' @param ... extra parameters passed to the constructor.
#'
#' @export
Expand All @@ -18,7 +18,7 @@ pmt <- function(key, ...) {
stop(
"The key '", key,
"' is not valid. ",
"Check 'pmts' for valid keys."
"Check `pmts()` for valid keys."
)
}
}
Expand Down
12 changes: 8 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ library(LearnNonparam)

This package implements some of the non-parametric tests in chapters 1-5 of [@Higgins2003](#references).

It depends on [R6](https://CRAN.R-project.org/package=R6) for object oriented design and [Rcpp](https://CRAN.R-project.org/package=Rcpp) for integration of R and C++.

Examples in the book can be found [here](https://qddyy.github.io/LearnNonparam/articles/examples).

## Installation
Expand All @@ -40,12 +42,13 @@ pak::pkg_install("qddyy/LearnNonparam")

## Usage

- Create a test object (for example, a `Wilcoxon` object)
- Construct a test object
- from some R6 class directly
```{r, eval = FALSE}
t <- Wilcoxon$new(alternative = "two_sided", type = "permu", n_permu = 1e6)
```
or you can use `pmt` (**p**er**m**utation **t**est) function (*Recommended*):
- using `pmt` (**p**er**m**utation **t**est) function (*recommended*)
```{r, create}
t <- pmt("twosample.wilcoxon", alternative = "two_sided", type = "permu", n_permu = 1e6)
```
Expand All @@ -57,21 +60,22 @@ pak::pkg_install("qddyy/LearnNonparam")
- Check the results
```{r, results}
t$statistic
t$p_value
t$print(digits = 2)
t$plot(style = "ggplot2", binwidth = 1)
```
- Modify some attributes and see how the results change
- Modify some active bindings and see how the results change
```{r, modify}
t$type <- "asymp"
t$p_value
```
implemented:
Tests implemented in this package:
```{r}
pmts()
Expand Down
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ check](https://github.com/qddyy/LearnNonparam/workflows/R-CMD-check/badge.svg)](
This package implements some of the non-parametric tests in chapters 1-5
of [Higgins (2003)](#references).

It depends on [R6](https://CRAN.R-project.org/package=R6) for object
oriented design and [Rcpp](https://CRAN.R-project.org/package=Rcpp) for
integration of R and C++.

Examples in the book can be found
[here](https://qddyy.github.io/LearnNonparam/articles/examples).

Expand All @@ -28,14 +32,15 @@ pak::pkg_install("qddyy/LearnNonparam")

## Usage

- Create a test object (for example, a `Wilcoxon` object)
- Construct a test object

- from some R6 class directly

``` r
t <- Wilcoxon$new(alternative = "two_sided", type = "permu", n_permu = 1e6)
```

or you can use `pmt` (**p**er**m**utation **t**est) function
(*Recommended*):
- using `pmt` (**p**er**m**utation **t**est) function (*recommended*)

``` r
t <- pmt("twosample.wilcoxon", alternative = "two_sided", type = "permu", n_permu = 1e6)
Expand All @@ -50,35 +55,37 @@ pak::pkg_install("qddyy/LearnNonparam")
- Check the results

``` r
t$statistic
#> [1] 526
t$p_value
#> [1] 0.000103
#> [1] 0.000611

t$print(digits = 2)
#>
#> Two Sample Wilcoxon Test
#>
#> scoring: rank type: permu(1e+06) method: default
#> statistic = 542, p-value = 1e-04
#> statistic = 526, p-value = 0.00061
#> alternative hypothesis: true location shift is not equal to 0
#> estimate: 1.1
#> 95% confidence interval: (0.56, 1.7)
#> estimate: 1.2
#> 95% confidence interval: (0.43, 1.9)

t$plot(style = "ggplot2", binwidth = 1)
#> Loading required namespace: ggplot2
```

<img src="man/figures/README-results-1.svg" width="100%" />

- Modify some attributes and see how the results change
- Modify some active bindings and see how the results change

``` r
t$type <- "asymp"

t$p_value
#> [1] 0.0003749904
#> [1] 0.001782376
```

implemented:
Tests implemented in this package:

``` r
pmts()
Expand Down
2 changes: 1 addition & 1 deletion man/PermuTest.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8342ebd

Please sign in to comment.