Learn R Programming

Connection (version 0.1.0)

Chi_squared: Chi-squared Statistic for Association Between Two Variables

Description

Calculates the Chi-squared statistic from a contingency table constructed using two input vectors. Both parameters can be a categorical (non-numeric) variable, allowing flexibility in input types. Variable a is used as rows, and b as columns in the contingency table.

Usage

Chi_squared(a, b)

Value

The Chi-squared statistic measuring association between the variables.

Arguments

a

First array or vector. Can be numeric or a categorical factor.

b

Second array or vector. Can be numeric or a categorical factor.

Examples

Run this code
Chi_squared(c(1, 3, 3, 6, 10), c("a", "b", "c", "d", "e"))

Run the code above in your browser using DataLab