Skip to content

Commit

Permalink
Merge branch 'develop' into paper
Browse files Browse the repository at this point in the history
  • Loading branch information
wleoncio committed Nov 13, 2023
2 parents 2329cdf + 3313e9c commit 0a51447
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
^Meta$
paper
Makefile
^CRAN-SUBMISSION$
^cran-comments\.md$
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 0.2.0
Date: 2023-11-07 08:27:25 UTC
SHA: 543f1ca2fb82489effd0178f2be3f9fec5e9f68b
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Package: permChacko
Title: Chacko Test for Order-Restriction with Permutation
Version: 0.1.0.9014
Version: 0.2.0.9000
Date: 2023-11-07
Authors@R:
c(
person(
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# permChacko (development version)

* Improved printing of hypothesis ([issue #11](https://github.com/ocbe-uio/permChacko/issues/11)).

# permChacko 0.2.0

* Replaced `verbose` with `verbosity` in functions to allow for more control over the output ([issue #3](https://github.com/ocbe-uio/permChacko/issues/3)).
* Exported `reduceVector()` ([issue #4](https://github.com/ocbe-uio/permChacko/issues/4)).
* Added package documentation ([issue #5](https://github.com/ocbe-uio/permChacko/issues/5)).
Expand Down
17 changes: 15 additions & 2 deletions R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ print.chacko_test <- function(x, ...) {
" Numeric p-value : %f (%d permutations)\n",
" Tabular p-value : %f\n"
),
paste0("p", seq_along(x$observed_data), collapse = " == "),
paste0("p", seq_along(x$observed_data), collapse = " <= "),
printHypothesis("p", seq_along(x$observed_data), "=="),
printHypothesis("p", seq_along(x$observed_data), "<="),
x[["statistic"]], p_values[["analytic"]],
p_values[["numeric"]], x[["n_perm"]], p_values[["tabular"]]
)
Expand All @@ -35,3 +35,16 @@ print.reduced_vector <- function(x, details = TRUE, ...) {
)
)
}

printHypothesis <- function(x_name, x_indices, operator = "==") {
operator <- paste0(" ", operator, " ")
if (length(x_indices) < 6) {
return(paste0(x_name, x_indices, collapse = operator))
} else {
first_idx <- 1:2
last_idx <- seq(length(x_indices) - 1, length(x_indices))
first_x <- paste0(x_name, x_indices[first_idx], collapse = operator)
last_x <- paste0(x_name, x_indices[last_idx], collapse = operator)
paste0(first_x, operator, "...", operator, last_x)
}
}
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# permChacko

permChacko is an R package that implements a modified version of the Chacko (1966) algorithm for order restriction.
permChacko is an R package that implements a modified version of the [Chacko (1966)](https://www.jstor.org/stable/25051572) algorithm for order restriction.

## Installation

Expand Down Expand Up @@ -32,10 +32,16 @@ library(permChacko)
permChacko(chacko66_sec3) # example 5 from Chacko (1966)
```

# Contributing and support
## Contributing and support

If you find a bug or have a feature request, please open an issue [here](https://github.com/ocbe-uio/permChacko/issues). If you would like to contribute with code, please see [here](https://github.com/ocbe-uio/permChacko/contribute) for a list of good issues for newcomers.

## References

Chacko, V. J. "Testing homogeneity against ordered alternatives." The Annals of Mathematical Statistics (1963): 945-956. https://www.jstor.org/stable/2238476

Chacko, V. J. (1966). Modified Chi-Square Test for Ordered Alternatives. Sankhyā: The Indian Journal of Statistics, Series B (1960-2002), 28(3/4), 185–190. http://www.jstor.org/stable/25051572

## Badges

<!-- badges: start -->
Expand Down
5 changes: 5 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
4 changes: 4 additions & 0 deletions tests/testthat/test-print-and-summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ test_that("print.chacko_test() works as expected", {
test_that("summary.reduced_vector() works as expected", {
expect_output(summary(reduceVector(rpois(7, 7))), "has been reduced 3 times")
})
test_that("Hypothesis suppression works as expected", {
expect_output(print(permChacko(4:1)), "p1 == p2 == p3 == p4")
expect_output(print(permChacko(6:1)), "p1 == p2 == ... == p5 == p6")
})

0 comments on commit 0a51447

Please sign in to comment.