diff --git a/.Rbuildignore b/.Rbuildignore index dab6c02..13825d8 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -7,3 +7,5 @@ ^Meta$ paper Makefile +^CRAN-SUBMISSION$ +^cran-comments\.md$ diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION new file mode 100644 index 0000000..6f75bf0 --- /dev/null +++ b/CRAN-SUBMISSION @@ -0,0 +1,3 @@ +Version: 0.2.0 +Date: 2023-11-07 08:27:25 UTC +SHA: 543f1ca2fb82489effd0178f2be3f9fec5e9f68b diff --git a/DESCRIPTION b/DESCRIPTION index 0594750..cdcb925 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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( diff --git a/NEWS.md b/NEWS.md index ae07b6d..b20a6bc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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)). diff --git a/R/print.R b/R/print.R index fe85ed9..03ff8d7 100644 --- a/R/print.R +++ b/R/print.R @@ -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"]] ) @@ -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) + } +} diff --git a/README.md b/README.md index 185d65a..077f23e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..858617d --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,5 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. diff --git a/tests/testthat/test-print-and-summary.R b/tests/testthat/test-print-and-summary.R index 8b6af4b..3303430 100644 --- a/tests/testthat/test-print-and-summary.R +++ b/tests/testthat/test-print-and-summary.R @@ -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") +})