Group-Independence Test Function
This function takes in two variables of equal length, the first of which is a categorical variable, and performs a test of independence between them. It returns a character string with the results of that test for putting in a table.
independence.test( x, y, w = NA, factor.test = NA, numeric.test = NA, star.cutoffs = c(0.01, 0.05, 0.1), star.markers = c("***", "**", "*"), digits = 3, fixed.digits = FALSE, format = "{name}={stat}{stars}", opts = list() )
x |
A categorical variable. |
y |
A variable to test for independence with |
w |
A vector of weights to pass to the appropriate test. |
factor.test |
Used when |
numeric.test |
Used when |
star.cutoffs |
A numeric vector indicating the p-value cutoffs to use for reporting significance stars. Defaults to |
star.markers |
A character vector indicating the symbols to use to indicate significance cutoffs associated with |
digits |
Number of digits after the decimal to round the test statistic and p-value to. |
fixed.digits |
|
format |
The way in which the four elements returned by (or calculated after) the test - |
opts |
The options listed above, entered in named-list format. |
In an attempt (and perhaps an encouragement) to use this function in weird ways, and because it's not really expected to be used directly, input is not sanitized. Have fun!
data(mtcars) independence.test(mtcars$cyl,mtcars$mpg)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.