Skip to content

Commit

Permalink
don't run crosstabs examples on CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Mar 20, 2024
1 parent 9456291 commit 60273ae
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 154 deletions.
156 changes: 79 additions & 77 deletions man/contingency_table.Rd

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

156 changes: 79 additions & 77 deletions man/examples/examples-contingency-table.R
Original file line number Diff line number Diff line change
@@ -1,77 +1,79 @@
#### -------------------- 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"
)
if (identical(Sys.getenv("NOT_CRAN"), "true")) {
#### -------------------- 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"
)
}

0 comments on commit 60273ae

Please sign in to comment.