--- title: "pairPropTest" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{pairPropTest} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", digits = 2 ) library(coreStatsNMR) library(dplyr) library(tidyr) set.seed(1234) iris_wtd <- iris %>% mutate(rand_bin = as.character(sample(1:3, nrow(iris), replace = TRUE)), weight = sample(1:3, nrow(.), replace = TRUE), index = row_number(.)) ``` `pairPropTest` is a function for comparing a set of proportion pairs for statistically significant differences. ## Sample data `pairPropTest` applied to the `iris` dataset, after glancing at the first few rows of data. ```{r iris} head(iris_wtd) %>% knitr::kable() pairPropTest(iris_wtd, "index", "rand_bin", "Species") %>% head(8) %>% knitr::kable(digits = 2) ## Get underlying counts pairPropTest(iris_wtd, "index", "rand_bin", "Species", counts = TRUE) %>% head(8) %>% knitr::kable(digits = 2) ``` ## Weighted tests The package also supports weighted testing, using the `wtd.chi.sq()` function from the `weights` package. ```{r iris_wtd} wtdPairPropTest(iris_wtd, "index", "rand_bin", "Species", "weight") %>% head(8) %>% knitr::kable(digits = 2) ## Get underlying counts wtdPairPropTest(iris_wtd, "index", "rand_bin", "Species", "weight", counts = TRUE) %>% head(8) %>% knitr::kable(digits = 2) ## Use unadjusted p-values wtdPairPropTest(iris_wtd, "index", "rand_bin", "Species", "weight", p.adjust.method = "none") %>% head(8) %>% knitr::kable(digits = 2) ```