chisq_pval: P-value of chi-squared contingency table test

View source: R/funciones.R

chisq_pvalR Documentation

P-value of chi-squared contingency table test

Description

P-value of chi-squared contingency table test

Usage

chisq_pval(y, g, pvdigits = 4)

Arguments

y

A numeric vector (or factor). Row variable in contingency table.

g

A numeric vector (or factor). Column variable in contingency table.

pvdigits

number of digits for the p-value

Details

If conditions for the validity of chi squared test are not met (expected frequencies less than 5) a Fisher exact test is performed instead.

Value

p-value of the chi squared contingency table test chisq.test(table(y,g))

Examples

df <- data.frame(g=rbinom(100,4,0.5),y=rnorm(sample(c(1:2),100,replace=TRUE)))
chisq_pval(df$y,df$g,pvdigits=3)

angeloSdP/reportingTools documentation built on Dec. 25, 2024, 11:19 a.m.