chisq_wrap: Chi-square wrapper

Description Usage Arguments Examples

View source: R/chisq_wrap.R

Description

This function is wraps the chisq.test function from the stats package to automatically simulate the p-value if the data provided does not comply with the assumptions of the Chi-square test, specifically that there is at least one cell with less than 5 expected counts.

Usage

1
chisq_wrap(x, y = NULL, ...)

Arguments

x

a numeric vector or matrix. x and y can also both be factors.

y

a numeric vector; ignored if x is a matrix. If x is a factor, y should be a factor of the same length.

...

passes options to the function

Examples

1
2
3
4
5
6
7
8
chisq_wrap(testdata$extortion_victim, testdata$size)

# x is a matrix or an object that can be coerced into a matrix
t <- table(testdata$extortion_victim, testdata$size)
chisq_wrap(t)

# Pass number of replicates to be used if simulation is required
chisq_wrap(t, B = 1000)

prestevez/victim documentation built on Jan. 30, 2020, 7:16 p.m.