Skip to content

Commit

Permalink
Added histogram bins parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
timbeechey committed Feb 17, 2024
1 parent 419a0b5 commit 4521fc3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: opa
Type: Package
Title: An Implementation of Ordinal Pattern Analysis
Version: 0.8.2.008
Version: 0.8.2.010
Authors@R: person("Timothy", "Beechey", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0001-8858-946X"))
Description: Quantifies hypothesis to data fit for repeated measures
Expand Down
14 changes: 8 additions & 6 deletions R/compare_pccs.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ compare_hypotheses.opafit <- function(m1, m2) {
#' Plot a histogram of PCCs computed from randomly reordered data
#' used to calculate the chance-value for a hypothesis comparison.
#' @param x an object of class "oparandpccs" produced by \code{random_pccs()}
#' @param nbins number of histogram bins
#' @param ... ignored
#' @return no return value, called for side effects only.
#' @examples
Expand All @@ -81,13 +82,13 @@ compare_hypotheses.opafit <- function(m1, m2) {
#' z <- compare_hypotheses(opamod1, opamod2)
#' plot(z)
#' @export
plot.opaHypothesisComparison <- function(x, ...) {
plot.opaHypothesisComparison <- function(x, nbins = 10, ...) {
histogram(x$pcc_diff_dist, type = "count", xlab = "PCC",
xlim = c(NA, min(max(max(x$pcc_diff_dist), x$pcc_diff) + 5, 105)),
ylab = "Count", col = "#56B4E9",
ylab = "Count", col = "#56B4E9", breaks = nbins,
panel = function(...) {
panel.histogram(...)
panel.abline(v = x$pcc_diff,
panel.abline(v = c(x$pcc_diff, -x$pcc_diff),
col = "red",
lty = 2)
}
Expand Down Expand Up @@ -194,6 +195,7 @@ compare_groups.opafit <- function(m, group1, group2) {
#' Plot a histogram of PCCs computed from randomly reordered data
#' used to calculate the chance-value for a group comparison.
#' @param x an object of class "oparandpccs" produced by \code{random_pccs()}
#' @param nbins number of histogram bins
#' @param ... ignored
#' @return no return value, called for side effects only.
#' @examples
Expand All @@ -207,13 +209,13 @@ compare_groups.opafit <- function(m, group1, group2) {
#' z <- compare_groups(opamod, "a", "b")
#' plot(z)
#' @export
plot.opaGroupComparison <- function(x, ...) {
plot.opaGroupComparison <- function(x, nbins = 10, ...) {
histogram(x$pcc_diff_dist, type = "count", xlab = "PCC",
xlim = c(NA, min(max(max(x$pcc_diff_dist), x$pcc_diff) + 5, 105)),
ylab = "Count", col = "#56B4E9",
ylab = "Count", col = "#56B4E9", breaks = nbins,
panel = function(...) {
panel.histogram(...)
panel.abline(v = x$pcc_diff,
panel.abline(v = c(x$pcc_diff, -x$pcc_diff),
col = "red",
lty = 2)
}
Expand Down
5 changes: 3 additions & 2 deletions R/utility.R
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ random_pccs.opafit <- function(m) {
#' Plot a histogram of PCCs computed from randomly reordered data
#' used to calculate the chance-value.
#' @param x an object of class "oparandpccs" produced by \code{random_pccs()}
#' @param nbins number of histogram bins
#' @param ... ignored
#' @return no return value, called for side effects only.
#' @examples
Expand All @@ -640,10 +641,10 @@ random_pccs.opafit <- function(m) {
#' opamod <- opa(dat, h)
#' plot(random_pccs(opamod))
#' @export
plot.oparandpccs <- function(x, ...) {
plot.oparandpccs <- function(x, nbins = 10, ...) {
histogram(unclass(x), type = "count", xlab = "PCC",
xlim = c(NA, min(max(max(x), attr(x, "observed_pcc")) + 5, 105)),
ylab = "Count", col = "#56B4E9",
ylab = "Count", col = "#56B4E9", breaks = nbins,
panel = function(...) {
panel.histogram(...)
panel.abline(v = attr(x, "observed_pcc"),
Expand Down
4 changes: 3 additions & 1 deletion man/plot.opaGroupComparison.Rd

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

4 changes: 3 additions & 1 deletion man/plot.opaHypothesisComparison.Rd

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

4 changes: 3 additions & 1 deletion man/plot.oparandpccs.Rd

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

0 comments on commit 4521fc3

Please sign in to comment.