Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

chisq_test

Tidy chi-squared test


Description

A tidier version of chisq.test() for goodness of fit tests and tests of independence.

Usage

chisq_test(x, formula, response = NULL, explanatory = NULL, ...)

Arguments

x

A data frame that can be coerced into a tibble.

formula

A formula with the response variable on the left and the explanatory on the right.

response

The variable name in x that will serve as the response. This is alternative to using the formula argument.

explanatory

The variable name in x that will serve as the explanatory variable.

...

Additional arguments for chisq.test().

Examples

# chi-squared test of independence for college completion
# status depending on one's self-identified income class
chisq_test(gss, college ~ finrela)

# chi-squared goodness of fit test on whether self-identified
# income class follows a uniform distribution
chisq_test(gss,
           response = finrela,
           p = c("far below average" = 1/6,
                 "below average" = 1/6,
                 "average" = 1/6,
                 "above average" = 1/6,
                 "far above average" = 1/6,
                 "DK" = 1/6))

infer

Tidy Statistical Inference

v0.5.4
CC0
Authors
Andrew Bray [aut, cre], Chester Ismay [aut] (<https://orcid.org/0000-0003-2820-2547>), Evgeni Chasnovski [aut] (<https://orcid.org/0000-0002-1617-4019>), Ben Baumer [aut] (<https://orcid.org/0000-0002-3279-0516>), Mine Cetinkaya-Rundel [aut] (<https://orcid.org/0000-0001-6452-2420>), Simon Couch [ctb], Ted Laderas [ctb] (<https://orcid.org/0000-0002-6207-7068>), Nick Solomon [ctb], Johanna Hardin [ctb], Albert Y. Kim [ctb] (<https://orcid.org/0000-0001-7824-306X>), Neal Fultz [ctb], Doug Friedman [ctb], Richie Cotton [ctb] (<https://orcid.org/0000-0003-2504-802X>), Brian Fannin [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.