diff --git a/.gitattributes b/.gitattributes index db970673..45714675 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,15 +9,15 @@ *.rds binary *.Rd text *.Rdx binary -*.Rmd text +*.Rmd text *.R text eol=crlf *.Rproj text *.[Rr]md linguist-detectable # Documentation files # ============================= -docs/* linguist-documentation -man/* linguist-documentation -misc/* linguist-documentation -pkgdown/* linguist-documentation -*.html linguist-documentation +docs/* linguist-documentation +man/* linguist-documentation +misc/* linguist-documentation +pkgdown/* linguist-documentation +*.html linguist-documentation diff --git a/.github/workflows/R-CMD-check-devel.yaml b/.github/workflows/R-CMD-check-devel.yaml index 263e475b..967753dc 100644 --- a/.github/workflows/R-CMD-check-devel.yaml +++ b/.github/workflows/R-CMD-check-devel.yaml @@ -24,16 +24,15 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: - #r-version: "devel" - http-user-agent: "release" + r-version: "devel" use-public-rspm: true # only download hard deps under active development - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' needs: check - cache: false extra-packages: | any::rcmdcheck easystats/insight diff --git a/.github/workflows/R-CMD-check-hard.yaml b/.github/workflows/R-CMD-check-hard.yaml index 93b98885..fb4c5560 100644 --- a/.github/workflows/R-CMD-check-hard.yaml +++ b/.github/workflows/R-CMD-check-hard.yaml @@ -36,6 +36,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' dependencies: '"hard"' cache: false extra-packages: | diff --git a/.github/workflows/R-CMD-check-strict.yaml b/.github/workflows/R-CMD-check-strict.yaml index 45747d45..56609dd8 100644 --- a/.github/workflows/R-CMD-check-strict.yaml +++ b/.github/workflows/R-CMD-check-strict.yaml @@ -50,6 +50,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' needs: check extra-packages: | any::rcmdcheck diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index fe9ffa88..e498ba6c 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -22,7 +22,7 @@ jobs: # `R-CMD-check-strict` workflow #- { os: macos-latest, r: "devel" } - #- { os: macos-latest, r: "release" } + - { os: macos-latest, r: "release" } - { os: macos-latest, r: "oldrel-1" } #- { os: windows-latest, r: "devel" } @@ -30,7 +30,7 @@ jobs: - { os: windows-latest, r: "oldrel-1" } #- { os: ubuntu-latest, r: "devel" } - - { os: ubuntu-latest, r: "release" } + #- { os: ubuntu-latest, r: "release" } #- { os: ubuntu-latest, r: "oldrel-1" } env: @@ -52,6 +52,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' extra-packages: | any::rcmdcheck needs: check diff --git a/.github/workflows/check-all-examples.yaml b/.github/workflows/check-all-examples.yaml index fca9046d..ba24579e 100644 --- a/.github/workflows/check-all-examples.yaml +++ b/.github/workflows/check-all-examples.yaml @@ -30,12 +30,13 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: - #r-version: "devel" + r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' extra-packages: | any::devtools local::. diff --git a/.github/workflows/check-link-rot.yaml b/.github/workflows/check-link-rot.yaml index 7d5a0e2e..75f76750 100644 --- a/.github/workflows/check-link-rot.yaml +++ b/.github/workflows/check-link-rot.yaml @@ -25,12 +25,13 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: - #r-version: "devel" + r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' dependencies: '"hard"' extra-packages: | any::rcmdcheck diff --git a/.github/workflows/check-random-test-order.yaml b/.github/workflows/check-random-test-order.yaml index 7fa7b831..55dfd62c 100644 --- a/.github/workflows/check-random-test-order.yaml +++ b/.github/workflows/check-random-test-order.yaml @@ -18,12 +18,13 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: - #r-version: "devel" + r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' extra-packages: | local::. diff --git a/.github/workflows/check-readme.yaml b/.github/workflows/check-readme.yaml index dc9cf2cd..9e3ffcd2 100644 --- a/.github/workflows/check-readme.yaml +++ b/.github/workflows/check-readme.yaml @@ -41,6 +41,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' extra-packages: | local::. any::gghalves diff --git a/.github/workflows/check-spelling.yaml b/.github/workflows/check-spelling.yaml index 3b862c34..6c26f5d7 100644 --- a/.github/workflows/check-spelling.yaml +++ b/.github/workflows/check-spelling.yaml @@ -30,6 +30,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' dependencies: '"hard"' extra-packages: | any::rcmdcheck diff --git a/.github/workflows/check-styling.yaml b/.github/workflows/check-styling.yaml index da20ab4b..4e79ce89 100644 --- a/.github/workflows/check-styling.yaml +++ b/.github/workflows/check-styling.yaml @@ -26,6 +26,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' dependencies: '"hard"' extra-packages: | local::. diff --git a/.github/workflows/check-test-warnings.yaml b/.github/workflows/check-test-warnings.yaml index 28a2ceb5..f17812e6 100644 --- a/.github/workflows/check-test-warnings.yaml +++ b/.github/workflows/check-test-warnings.yaml @@ -22,12 +22,13 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: - #r-version: "devel" + r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' extra-packages: | local::. any::devtools diff --git a/.github/workflows/check-vignette-warnings.yaml b/.github/workflows/check-vignette-warnings.yaml index cd929ac4..152d6c3e 100644 --- a/.github/workflows/check-vignette-warnings.yaml +++ b/.github/workflows/check-vignette-warnings.yaml @@ -26,12 +26,13 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: - #r-version: "devel" + r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' extra-packages: | local::. diff --git a/.github/workflows/html-5-check.yaml b/.github/workflows/html-5-check.yaml index c1a781e9..36acbd80 100644 --- a/.github/workflows/html-5-check.yaml +++ b/.github/workflows/html-5-check.yaml @@ -19,12 +19,13 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: - #r-version: "devel" + r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' extra-packages: | any::rcmdcheck any::V8 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 42552dfd..f6951746 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -27,6 +27,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' extra-packages: | r-lib/lintr local::. diff --git a/.github/workflows/pkgdown-no-suggests.yaml b/.github/workflows/pkgdown-no-suggests.yaml index cc845710..3cc92197 100644 --- a/.github/workflows/pkgdown-no-suggests.yaml +++ b/.github/workflows/pkgdown-no-suggests.yaml @@ -34,6 +34,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' dependencies: '"hard"' cache: false extra-packages: | diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index ff6fbbe4..e6ed3dc3 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -28,11 +28,13 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: + r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' extra-packages: | r-lib/pkgdown local::. diff --git a/.github/workflows/styler.yaml b/.github/workflows/styler.yaml index ef8fd1aa..58f021fb 100644 --- a/.github/workflows/styler.yaml +++ b/.github/workflows/styler.yaml @@ -24,6 +24,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' dependencies: '"hard"' extra-packages: | local::. diff --git a/.github/workflows/test-coverage-examples.yaml b/.github/workflows/test-coverage-examples.yaml index 61ac89f4..9e5457b5 100644 --- a/.github/workflows/test-coverage-examples.yaml +++ b/.github/workflows/test-coverage-examples.yaml @@ -20,11 +20,13 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: + r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' extra-packages: | any::covr local::. diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 733d809e..beb317ac 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -19,11 +19,13 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: + r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel + upgrade: 'TRUE' extra-packages: | any::covr needs: coverage diff --git a/CITATION.cff b/CITATION.cff index 563f6d94..d76ae412 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -95,7 +95,7 @@ references: - family-names: Ben-Shachar given-names: Mattan S. year: '2024' - version: '>= 1.3-0' + version: '>= 1.3-1' - type: software title: BayesFactor abstract: 'BayesFactor: Computation of Bayes Factors for Common Designs' @@ -110,7 +110,7 @@ references: given-names: Jeffrey N. email: jrouder@uci.edu year: '2024' - version: '>= 0.9.12-4.6' + version: '>= 0.9.12-4.7' - type: software title: correlation abstract: 'correlation: Methods for Correlation Analysis' @@ -259,7 +259,7 @@ references: abstract: 'insight: Easy Access to Model Information for Various Model Objects' notes: Imports url: https://easystats.github.io/insight/ - repository: https://CRAN.R-project.org/package=insight + repository: https://easystats.r-universe.dev authors: - family-names: Lüdecke given-names: Daniel @@ -314,7 +314,7 @@ references: abstract: 'parameters: Processing of Model Parameters' notes: Imports url: https://easystats.github.io/parameters/ - repository: https://CRAN.R-project.org/package=parameters + repository: https://easystats.r-universe.dev authors: - family-names: Lüdecke given-names: Daniel @@ -346,7 +346,7 @@ references: abstract: 'performance: Assessment of Regression Models Performance' notes: Imports url: https://easystats.github.io/performance/ - repository: https://CRAN.R-project.org/package=performance + repository: https://easystats.r-universe.dev authors: - family-names: Lüdecke given-names: Daniel @@ -376,8 +376,8 @@ references: given-names: Rémi email: remi.theriault@mail.mcgill.ca orcid: https://orcid.org/0000-0003-4315-6788 - version: '>= 0.10.8' year: '2024' + version: '>= 0.10.9' - type: software title: PMCMRplus abstract: 'PMCMRplus: Calculate Pairwise Multiple Comparisons of Mean Rank Sums @@ -581,6 +581,9 @@ references: - family-names: Dunnington given-names: Dewey orcid: https://orcid.org/0000-0002-9415-4582 + - family-names: van den Brand + given-names: Teun + orcid: https://orcid.org/0000-0002-9335-7468 year: '2024' - type: software title: knitr diff --git a/DESCRIPTION b/DESCRIPTION index d4551769..695adca2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,8 +25,8 @@ BugReports: https://github.com/IndrajeetPatil/statsExpressions/issues Depends: R (>= 4.1.0) Imports: - afex (>= 1.3-0), - BayesFactor (>= 0.9.12-4.6), + afex (>= 1.3-1), + BayesFactor (>= 0.9.12-4.7), correlation (>= 0.8.4), datawizard (>= 0.9.1), dplyr (>= 1.1.4), @@ -35,7 +35,7 @@ Imports: insight (>= 0.19.8), magrittr, parameters (>= 0.21.5), - performance (>= 0.10.8), + performance (>= 0.10.9), PMCMRplus, purrr (>= 1.0.2), rlang, diff --git a/R/contingency-table.R b/R/contingency-table.R index b8db5bd0..c9ed5577 100644 --- a/R/contingency-table.R +++ b/R/contingency-table.R @@ -20,14 +20,11 @@ #' @param x The variable to use as the **rows** in the contingency table. #' @param y The variable to use as the **columns** in the contingency table. #' Default is `NULL`. If `NULL`, one-sample proportion test (a goodness of fit -#' test) will be run for the `x` variable. Otherwise association test will be -#' carried out. +#' test) will be run for the `x` variable. #' @param counts The variable in data containing counts, or `NULL` if each row #' represents a single observation. #' @param paired Logical indicating whether data came from a within-subjects or -#' repeated measures design study (Default: `FALSE`). If `TRUE`, McNemar's -#' test expression will be returned. If `FALSE`, Pearson's chi-square test will -#' be returned. +#' repeated measures design study (Default: `FALSE`). #' @param sampling.plan Character describing the sampling plan. Possible options #' are `"indepMulti"` (independent multinomial; default), `"poisson"`, #' `"jointMulti"` (joint multinomial), `"hypergeom"` (hypergeometric). For @@ -39,58 +36,17 @@ #' hypothesis under the alternative, and corresponds to Gunel and Dickey's #' (1974) `"a"` parameter. #' @param ratio A vector of proportions: the expected proportions for the -#' proportion test (should sum to 1). Default is `NULL`, which means the null +#' proportion test (should sum to `1`). Default is `NULL`, which means the null #' is equal theoretical proportions across the levels of the nominal variable. -#' This means if there are two levels this will be `ratio = c(0.5,0.5)` or if -#' there are four levels this will be `ratio = c(0.25,0.25,0.25,0.25)`, etc. +#' E.g., `ratio = c(0.5, 0.5)` for two levels, +#' `ratio = c(0.25, 0.25, 0.25, 0.25)` for four levels, etc. #' @param ... Additional arguments (currently ignored). #' @inheritParams stats::chisq.test #' @inheritParams oneway_anova #' #' @autoglobal #' -#' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true") -#' # for reproducibility -#' set.seed(123) -#' library(statsExpressions) -#' -#' # ------------------------ Frequentist ----------------------------- -#' -#' # association test -#' contingency_table( -#' data = mtcars, -#' x = am, -#' y = vs, -#' paired = FALSE -#' ) -#' -#' # goodness-of-fit test -#' contingency_table( -#' data = as.data.frame(HairEyeColor), -#' x = Eye, -#' counts = Freq, -#' ratio = c(0.2, 0.2, 0.3, 0.3) -#' ) -#' -#' # ------------------------ Bayesian ----------------------------- -#' -#' # association test -#' contingency_table( -#' data = mtcars, -#' x = am, -#' y = vs, -#' paired = FALSE, -#' type = "bayes" -#' ) -#' -#' # goodness-of-fit test -#' contingency_table( -#' data = as.data.frame(HairEyeColor), -#' x = Eye, -#' counts = Freq, -#' ratio = c(0.2, 0.2, 0.3, 0.3), -#' type = "bayes" -#' ) +#' @example man/examples/examples-contingency-table.R #' @export contingency_table <- function( data, diff --git a/README.Rmd b/README.Rmd index 2f95c443..1bbd30f3 100644 --- a/README.Rmd +++ b/README.Rmd @@ -446,7 +446,7 @@ more about how one-way (between-subjects) ANOVA, you can run ```{r, child = "man/rmd-fragments/meta_analysis.Rmd"} ``` -# Usage in `ggstatsplot` +# Usage in `{ggstatsplot}` Note that these functions were initially written to display results from statistical tests on ready-made `{ggplot2}` plots implemented in `{ggstatsplot}`. diff --git a/README.md b/README.md index 29aab8aa..2a24abbf 100644 --- a/README.md +++ b/README.md @@ -682,7 +682,7 @@ console. | Robust | Meta-analysis via robust random-effects models | *beta* | Yes | `metaplus::metaplus()` | | Bayes | Meta-analysis via Bayesian random-effects models | *beta* | Yes | `metaBMA::meta_random()` | -# Usage in `ggstatsplot` +# Usage in `{ggstatsplot}` Note that these functions were initially written to display results from statistical tests on ready-made `{ggplot2}` plots implemented in diff --git a/codemeta.json b/codemeta.json index 2171c11e..566a8575 100644 --- a/codemeta.json +++ b/codemeta.json @@ -188,7 +188,7 @@ "@type": "SoftwareApplication", "identifier": "afex", "name": "afex", - "version": ">= 1.3-0", + "version": ">= 1.3-1", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -201,7 +201,7 @@ "@type": "SoftwareApplication", "identifier": "BayesFactor", "name": "BayesFactor", - "version": ">= 0.9.12-4.6", + "version": ">= 0.9.12-4.7", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -316,7 +316,7 @@ "@type": "SoftwareApplication", "identifier": "performance", "name": "performance", - "version": ">= 0.10.8", + "version": ">= 0.10.9", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -432,7 +432,7 @@ }, "SystemRequirements": null }, - "fileSize": "4131.204KB", + "fileSize": "4130.456KB", "citation": [ { "@type": "ScholarlyArticle", diff --git a/man/contingency_table.Rd b/man/contingency_table.Rd index ce4903cd..66b45299 100644 --- a/man/contingency_table.Rd +++ b/man/contingency_table.Rd @@ -30,13 +30,10 @@ ungrouped before they are entered as \code{data}.} \item{y}{The variable to use as the \strong{columns} in the contingency table. Default is \code{NULL}. If \code{NULL}, one-sample proportion test (a goodness of fit -test) will be run for the \code{x} variable. Otherwise association test will be -carried out.} +test) will be run for the \code{x} variable.} \item{paired}{Logical indicating whether data came from a within-subjects or -repeated measures design study (Default: \code{FALSE}). If \code{TRUE}, McNemar's -test expression will be returned. If \code{FALSE}, Pearson's chi-square test will -be returned.} +repeated measures design study (Default: \code{FALSE}).} \item{type}{A character specifying the type of statistical approach: \itemize{ @@ -52,10 +49,10 @@ You can specify just the initial letter.} represents a single observation.} \item{ratio}{A vector of proportions: the expected proportions for the -proportion test (should sum to 1). Default is \code{NULL}, which means the null +proportion test (should sum to \code{1}). Default is \code{NULL}, which means the null is equal theoretical proportions across the levels of the nominal variable. -This means if there are two levels this will be \code{ratio = c(0.5,0.5)} or if -there are four levels this will be \code{ratio = c(0.25,0.25,0.25,0.25)}, etc.} +E.g., \code{ratio = c(0.5, 0.5)} for two levels, +\code{ratio = c(0.25, 0.25, 0.25, 0.25)} for four levels, etc.} \item{k}{Number of digits after decimal point (should be an integer) (Default: \code{k = 2L}).} @@ -154,14 +151,13 @@ The table below provides summary about: } \examples{ -\dontshow{if (identical(Sys.getenv("NOT_CRAN"), "true")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -# for reproducibility -set.seed(123) -library(statsExpressions) +#### -------------------- association test ------------------------ #### + +# ------------------------ frequentist --------------------------------- -# ------------------------ Frequentist ----------------------------- +# unpaired -# association test +set.seed(123) contingency_table( data = mtcars, x = am, @@ -169,26 +165,62 @@ contingency_table( paired = FALSE ) -# goodness-of-fit test +# paired + +paired_data <- tibble( + response_before = structure(c(1L, 2L, 1L, 2L), levels = c("no", "yes"), class = "factor"), + response_after = structure(c(1L, 1L, 2L, 2L), levels = c("no", "yes"), class = "factor"), + Freq = c(65L, 25L, 5L, 5L) +) + +set.seed(123) contingency_table( - data = as.data.frame(HairEyeColor), - x = Eye, - counts = Freq, - ratio = c(0.2, 0.2, 0.3, 0.3) + data = paired_data, + x = response_before, + y = response_after, + paired = TRUE, + counts = Freq ) -# ------------------------ Bayesian ----------------------------- +# ------------------------ Bayesian ------------------------------------- -# association test +# unpaired + +set.seed(123) contingency_table( - data = mtcars, - x = am, - y = vs, + data = mtcars, + x = am, + y = vs, paired = FALSE, - type = "bayes" + type = "bayes" ) -# goodness-of-fit test +# paired + +set.seed(123) +contingency_table( + data = paired_data, + x = response_before, + y = response_after, + paired = TRUE, + counts = Freq, + type = "bayes" +) + +#### -------------------- goodness-of-fit test -------------------- #### + +# ------------------------ frequentist --------------------------------- + +set.seed(123) +contingency_table( + data = as.data.frame(HairEyeColor), + x = Eye, + counts = Freq +) + +# ------------------------ Bayesian ------------------------------------- + +set.seed(123) contingency_table( data = as.data.frame(HairEyeColor), x = Eye, @@ -196,5 +228,4 @@ contingency_table( ratio = c(0.2, 0.2, 0.3, 0.3), type = "bayes" ) -\dontshow{\}) # examplesIf} } diff --git a/man/examples/examples-contingency-table.R b/man/examples/examples-contingency-table.R new file mode 100644 index 00000000..f6bdd083 --- /dev/null +++ b/man/examples/examples-contingency-table.R @@ -0,0 +1,77 @@ +#### -------------------- association test ------------------------ #### + +# ------------------------ frequentist --------------------------------- + +# unpaired + +set.seed(123) +contingency_table( + data = mtcars, + x = am, + y = vs, + paired = FALSE +) + +# paired + +paired_data <- tibble( + response_before = structure(c(1L, 2L, 1L, 2L), levels = c("no", "yes"), class = "factor"), + response_after = structure(c(1L, 1L, 2L, 2L), levels = c("no", "yes"), class = "factor"), + Freq = c(65L, 25L, 5L, 5L) +) + +set.seed(123) +contingency_table( + data = paired_data, + x = response_before, + y = response_after, + paired = TRUE, + counts = Freq +) + +# ------------------------ Bayesian ------------------------------------- + +# unpaired + +set.seed(123) +contingency_table( + data = mtcars, + x = am, + y = vs, + paired = FALSE, + type = "bayes" +) + +# paired + +set.seed(123) +contingency_table( + data = paired_data, + x = response_before, + y = response_after, + paired = TRUE, + counts = Freq, + type = "bayes" +) + +#### -------------------- goodness-of-fit test -------------------- #### + +# ------------------------ frequentist --------------------------------- + +set.seed(123) +contingency_table( + data = as.data.frame(HairEyeColor), + x = Eye, + counts = Freq +) + +# ------------------------ Bayesian ------------------------------------- + +set.seed(123) +contingency_table( + data = as.data.frame(HairEyeColor), + x = Eye, + counts = Freq, + ratio = c(0.2, 0.2, 0.3, 0.3), + type = "bayes" +) diff --git a/man/figures/README-anova_parametric2-1.png b/man/figures/README-anova_parametric2-1.png index f98d0957..b71cc504 100644 Binary files a/man/figures/README-anova_parametric2-1.png and b/man/figures/README-anova_parametric2-1.png differ diff --git a/man/figures/README-centrality-1.png b/man/figures/README-centrality-1.png index 67d15d2e..45401349 100644 Binary files a/man/figures/README-centrality-1.png and b/man/figures/README-centrality-1.png differ diff --git a/man/figures/README-gof-1.png b/man/figures/README-gof-1.png index 059725b7..ceac6485 100644 Binary files a/man/figures/README-gof-1.png and b/man/figures/README-gof-1.png differ diff --git a/vignettes/web_only/dataframe_outputs.Rmd b/vignettes/web_only/dataframe_outputs.Rmd index bfb6942e..87d64756 100644 --- a/vignettes/web_only/dataframe_outputs.Rmd +++ b/vignettes/web_only/dataframe_outputs.Rmd @@ -181,76 +181,9 @@ oneway_anova( ## Contingency table analyses -### association test - -```{r} -#| label = "conttabs" - -# ------------------------ frequentist ----------------------------- - -# unpaired -set.seed(123) -contingency_table( - data = mtcars, - x = am, - y = vs, - paired = FALSE -) - -# paired -## example data -paired_data <- tibble( - response_before = structure(c(1L, 2L, 1L, 2L), levels = c("no", "yes"), class = "factor"), - response_after = structure(c(1L, 1L, 2L, 2L), levels = c("no", "yes"), class = "factor"), - Freq = c(65L, 25L, 5L, 5L) -) - -set.seed(123) -contingency_table( - data = paired_data, - x = response_before, - y = response_after, - paired = TRUE, - counts = "Freq" -) - -# ------------------------ Bayesian ----------------------------- - -# unpaired -set.seed(123) -contingency_table( - data = mtcars, - x = am, - y = vs, - paired = FALSE, - type = "bayes" -) -``` - -### goodness-of-fit tests - ```{r} -#| label = "gof" -# ------------------------ frequentist ----------------------------- - -# with counts -set.seed(123) -contingency_table( - data = as.data.frame(HairEyeColor), - x = Eye, - counts = Freq -) - -# ------------------------ Bayesian ----------------------------- - -set.seed(123) -contingency_table( - data = as.data.frame(HairEyeColor), - x = Eye, - counts = Freq, - ratio = c(0.2, 0.2, 0.3, 0.3), - type = "bayes" -) +#| label = "crosstabs", +#| file = "../../man/examples/examples-contingency-table.R" ``` ## Correlation analyses